diff --git a/config/src/main/java/com/typesafe/config/impl/ConfigImplUtil.java b/config/src/main/java/com/typesafe/config/impl/ConfigImplUtil.java index 257c2c41..279f5ec8 100644 --- a/config/src/main/java/com/typesafe/config/impl/ConfigImplUtil.java +++ b/config/src/main/java/com/typesafe/config/impl/ConfigImplUtil.java @@ -32,6 +32,10 @@ final public class ConfigImplUtil { return a.equals(b); } + static boolean isC0Control(int codepoint) { + return (codepoint >= 0x0000 && codepoint <= 0x001F); + } + public static String renderJsonString(String s) { StringBuilder sb = new StringBuilder(); sb.append('"'); @@ -60,7 +64,7 @@ final public class ConfigImplUtil { sb.append("\\t"); break; default: - if (Character.isISOControl(c)) + if (isC0Control(c)) sb.append(String.format("\\u%04x", (int) c)); else sb.append(c); diff --git a/config/src/main/java/com/typesafe/config/impl/Tokenizer.java b/config/src/main/java/com/typesafe/config/impl/Tokenizer.java index d421dfb8..0295ea58 100644 --- a/config/src/main/java/com/typesafe/config/impl/Tokenizer.java +++ b/config/src/main/java/com/typesafe/config/impl/Tokenizer.java @@ -38,7 +38,7 @@ final class Tokenizer { return "tab"; else if (codepoint == -1) return "end of file"; - else if (Character.isISOControl(codepoint)) + else if (ConfigImplUtil.isC0Control(codepoint)) return String.format("control character 0x%x", codepoint); else return String.format("%c", codepoint); @@ -498,7 +498,7 @@ final class Tokenizer { } else if (c == '"') { sbOrig.appendCodePoint(c); break; - } else if (Character.isISOControl(c)) { + } else if (ConfigImplUtil.isC0Control(c)) { throw problem(asString(c), "JSON does not allow unescaped " + asString(c) + " in quoted strings, use a backslash escape"); } else {