javaee / jaxb-codemodel

CodeModel is a Java library for code generators. This content is migrated into JAXB RI. This is for legacy viewing only
https://javaee.github.io/jaxb-codemodel/
Other
40 stars 20 forks source link

Forced unicode character escape in com.sun.codemodel.JExpr#quotify #30

Open Hubbitus opened 5 years ago

Hubbitus commented 5 years ago

com.sun.codemodel.JExpr#quotify have ancient comment and force unicode characters escape:

                // technically Unicode escape shouldn't be done here,
                // for it's a lexical level handling.
                // 
                // However, various tools are so broken around this area,
                // so just to be on the safe side, it's better to do
                // the escaping here (regardless of the actual file encoding)
                //
                // see bug 
                if( c<0x20 || 0x7E<c ) {
                    // not printable. use Unicode escape
                    sb.append("\\u");
                    String hex = Integer.toHexString(((int)c)&0xFFFF);
                    for( int k=hex.length(); k<4; k++ )
                        sb.append('0');
sb.append(hex);

I want my annotation values became unescaped in generated sources by JCB. I think in now days most compilers do not have any issues with it. So could you please just remove such block? Or at least provide option to disable.

Hubbitus commented 5 years ago

If you are willing I could make PR for that.

antonovdmitriy commented 3 years ago

Just spent a few hours today looking for an answer why the jsonscheme2pojo library, which uses the codemodel for generating java clasess, escapes characters in Jackson annotations.
image image image