diff --git a/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java b/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java index 5b2c74a..993ca2c 100644 --- a/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java +++ b/java/io/nayuki/qrcodegen/QrSegmentAdvanced.java @@ -257,13 +257,18 @@ public final class QrSegmentAdvanced { public static boolean isEncodableAsKanji(String text) { Objects.requireNonNull(text); for (int i = 0; i < text.length(); i++) { - if (UNICODE_TO_QR_KANJI[text.charAt(i)] == -1) + if (!isKanji(text.charAt(i))) return false; } return true; } + private static boolean isKanji(char c) { + return UNICODE_TO_QR_KANJI[c] != -1; + } + + // Data derived from ftp://ftp.unicode.org/Public/MAPPINGS/OBSOLETE/EASTASIA/JIS/SHIFTJIS.TXT private static final String PACKED_QR_KANJI_TO_UNICODE = "MAAwATAC/wz/DjD7/xr/G/8f/wEwmzCcALT/QACo/z7/4/8/MP0w/jCdMJ4wA07dMAUwBjAHMPwgFSAQ/w8AXDAcIBb/XCAmICUgGCAZIBwgHf8I/wkwFDAV/zv/Pf9b/10wCDAJMAowCzAMMA0wDjAPMBAwEf8LIhIAsQDX//8A9/8dImD/HP8eImYiZyIeIjQmQiZA" +