From 97e01334507bb37ab1d8ae46ecbf1a3e787f7e49 Mon Sep 17 00:00:00 2001 From: "moandji.ezana" Date: Tue, 14 Jul 2015 22:29:54 +0200 Subject: [PATCH] Write Unicode symbols instead of escaping them --- src/main/java/com/moandjiezana/toml/StringConverter.java | 5 +++++ src/test/java/com/moandjiezana/toml/TomlWriterTest.java | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/moandjiezana/toml/StringConverter.java b/src/main/java/com/moandjiezana/toml/StringConverter.java index 7888ae7..a69f468 100644 --- a/src/main/java/com/moandjiezana/toml/StringConverter.java +++ b/src/main/java/com/moandjiezana/toml/StringConverter.java @@ -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)); + } } } diff --git a/src/test/java/com/moandjiezana/toml/TomlWriterTest.java b/src/test/java/com/moandjiezana/toml/TomlWriterTest.java index 1c6f128..f8e3773 100644 --- a/src/test/java/com/moandjiezana/toml/TomlWriterTest.java +++ b/src/test/java/com/moandjiezana/toml/TomlWriterTest.java @@ -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