Added private helper method to Java QrSegmentAdvanced.

This commit is contained in:
Project Nayuki 2018-08-28 07:52:42 +00:00
parent 0bf2d3306b
commit 719caf4d99
1 changed files with 6 additions and 1 deletions

View File

@ -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" +