Skip to content

Unicode characters are not correctly parsed from byte[] if default charset is not UTF-8 #73

Closed
@dpeger

Description

@dpeger

The TestUtf8.supportI18nBytes test is currently broken on windows systems. Actually in my IDE (IntelliJ) the test is green. but the maven test target fails both in the IDE and on command line:

[ERROR] Failures:
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Amharic text ==> expected: <አማርኛ> but was: <አማርኛ>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Malayalam text ==> expected: <മലയാളം> but was: <മലയാളം>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Assyrian Neo-Aramaic text ==> expected: <ܐܬܘܪܝܐ> but was: <Ü?ܬܘܪÜ?Ü?>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Georgian text ==> expected: <მარგალური> but was: <მáƒ?რგáƒ?ლური>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Sinhala text ==> expected: <සිංහල ජාතිය> but was: <සිංහල à¶¢à·?තිය>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Japanese text ==> expected: <日本語> but was: <日本語>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Russian text ==> expected: <Русский> but was: <РуÑ?Ñ?кий>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Farsi text ==> expected: <فارسی> but was: <Ù?ارسی>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Korean text ==> expected: <한국어> but was: <한국어>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Armenian text ==> expected: <Հայերեն> but was: <Õ€Õ¡ÕµÕ¥Ö€Õ¥Õ¶>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Hindi text ==> expected: <हिन्दी> but was: <हिनà¥?दी>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Hebrew text ==> expected: <עברית> but was: <עברית>
[ERROR] TestUtf8.supportI18nBytes:62 Parsing bytes[] Chinese text ==> expected: <中文> but was: <中文>

The problem seems to be the creation of String using the system's default charset in JSONParserByteArray.extractString

xs = new String(in, beginIndex, endIndex - beginIndex);

and JSONParserByteArray.extractStringTrim

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions