diff --git a/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java b/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java index d234d48c65b..f4d431b53cd 100644 --- a/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java +++ b/src/main/java/org/apache/groovy/parser/antlr4/util/StringUtils.java @@ -59,7 +59,7 @@ public static String replaceHexEscapes(String text) { return replaceAll(text, HEX_ESCAPES_PATTERN, m -> { final String _0 = m.group(0), _1 = m.group(1), _2 = m.group(2); if (isLengthOdd(_1)) return _0; - return _1 + ((char) Integer.parseInt(_2, 16)); + return _1 + new String(Character.toChars(Integer.parseInt(_2, 16))); }); } @@ -68,7 +68,7 @@ public static String replaceOctalEscapes(String text) { return replaceAll(text, OCTAL_ESCAPES_PATTERN, m -> { final String _0 = m.group(0), _1 = m.group(1), _2 = m.group(2); if (isLengthOdd(_1)) return _0; - return _1 + ((char) Integer.parseInt(_2, 8)); + return _1 + new String(Character.toChars(Integer.parseInt(_2, 8))); }); }