mirror of
https://github.com/plexusorg/toml4j.git
synced 2024-12-29 11:42:15 +00:00
Write Unicode symbols instead of escaping them
This commit is contained in:
parent
c90d4e1e71
commit
97e0133450
2 changed files with 8 additions and 3 deletions
|
@ -113,6 +113,7 @@ class StringConverter implements ValueConverter, ValueWriter {
|
|||
int codePoint = in.codePointAt(i);
|
||||
if (codePoint < specialCharacterEscapes.length && specialCharacterEscapes[codePoint] != null) {
|
||||
context.write(specialCharacterEscapes[codePoint]);
|
||||
/*
|
||||
} else if (codePoint > 0x1f && codePoint < 0x7f) {
|
||||
context.write(Character.toChars(codePoint));
|
||||
} else if (codePoint <= 0xFFFF) {
|
||||
|
@ -122,6 +123,10 @@ class StringConverter implements ValueConverter, ValueWriter {
|
|||
// Skip the low surrogate, which will be the next in the code point sequence.
|
||||
i++;
|
||||
}
|
||||
*/
|
||||
} else {
|
||||
context.write(in.charAt(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -289,12 +289,12 @@ public class TomlWriterTest {
|
|||
}
|
||||
|
||||
Utf8Test utf8Test = new Utf8Test();
|
||||
utf8Test.input = " é foo € \b \t \n \f \r \" \\ ";
|
||||
assertEquals("input = \" \\u00E9 foo \\u20AC \\b \\t \\n \\f \\r \\\" \\\\ \"\n", new TomlWriter().write(utf8Test));
|
||||
utf8Test.input = " é foo \u20AC \b \t \n \f \r \" \\ ";
|
||||
assertEquals("input = \" é foo € \\b \\t \\n \\f \\r \\\" \\\\ \"\n", new TomlWriter().write(utf8Test));
|
||||
|
||||
// Check unicode code points greater than 0XFFFF
|
||||
utf8Test.input = " \uD801\uDC28 \uD840\uDC0B ";
|
||||
assertEquals("input = \" \\U00010428 \\U0002000B \"\n", new TomlWriter().write(utf8Test));
|
||||
assertEquals("input = \" 𐐨 𠀋 \"\n", new TomlWriter().write(utf8Test));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in a new issue