From 719caf4d99ee326c360e151ffb1f96f270276dbb Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Tue, 28 Aug 2018 07:52:42 +0000 Subject: [PATCH] Added private helper method to Java QrSegmentAdvanced. --- java/io/nayuki/qrcodegen/QrSegmentAdvanced.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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" +