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