Package io.nayuki.qrcodegen
Class QrSegmentAdvanced
java.lang.Object
io.nayuki.qrcodegen.QrSegmentAdvanced
public final class QrSegmentAdvanced
extends java.lang.Object
Splits text into optimal segments and encodes kanji segments.
Provides static functions only; not instantiable.
-
Method Summary
Modifier and Type Method Description static booleanisEncodableAsKanji(java.lang.String text)Tests whether the specified string can be encoded as a segment in kanji mode.static QrSegmentmakeKanji(java.lang.String text)Returns a segment representing the specified text string encoded in kanji mode.static java.util.List<QrSegment>makeSegmentsOptimally(java.lang.String text, QrCode.Ecc ecl, int minVersion, int maxVersion)Returns a list of zero or more segments to represent the specified Unicode text string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Method Details
-
makeSegmentsOptimally
public static java.util.List<QrSegment> makeSegmentsOptimally(java.lang.String text, QrCode.Ecc ecl, int minVersion, int maxVersion)Returns a list of zero or more segments to represent the specified Unicode text string. The resulting list optimally minimizes the total encoded bit length, subjected to the constraints in the specified {error correction level, minimum version number, maximum version number}.This function can utilize all four text encoding modes: numeric, alphanumeric, byte (UTF-8), and kanji. This can be considered as a sophisticated but slower replacement for
QrSegment.makeSegments(String). This requires more input parameters because it searches a range of versions, likeQrCode.encodeSegments(List,QrCode.Ecc,int,int,int,boolean).- Parameters:
text- the text to be encoded (notnull), which can be any Unicode stringecl- the error correction level to use (notnull)minVersion- the minimum allowed version of the QR Code (at least 1)maxVersion- the maximum allowed version of the QR Code (at most 40)- Returns:
- a new mutable list (not
null) of segments (notnull) containing the text, minimizing the bit length with respect to the constraints - Throws:
java.lang.NullPointerException- if the text or error correction level isnulljava.lang.IllegalArgumentException- if 1 ≤ minVersion ≤ maxVersion ≤ 40 is violatedDataTooLongException- if the text fails to fit in the maxVersion QR Code at the ECL
-
makeKanji
Returns a segment representing the specified text string encoded in kanji mode. Broadly speaking, the set of encodable characters are {kanji used in Japan, hiragana, katakana, East Asian punctuation, full-width ASCII, Greek, Cyrillic}. Examples of non-encodable characters include {ordinary ASCII, half-width katakana, more extensive Chinese hanzi}.- Parameters:
text- the text (notnull), with only certain characters allowed- Returns:
- a segment (not
null) containing the text - Throws:
java.lang.NullPointerException- if the string isnulljava.lang.IllegalArgumentException- if the string contains non-encodable characters- See Also:
isEncodableAsKanji(String)
-
isEncodableAsKanji
public static boolean isEncodableAsKanji(java.lang.String text)Tests whether the specified string can be encoded as a segment in kanji mode. Broadly speaking, the set of encodable characters are {kanji used in Japan, hiragana, katakana, East Asian punctuation, full-width ASCII, Greek, Cyrillic}. Examples of non-encodable characters include {ordinary ASCII, half-width katakana, more extensive Chinese hanzi}.- Parameters:
text- the string to test for encodability (notnull)- Returns:
trueiff each character is in the kanji mode character set- Throws:
java.lang.NullPointerException- if the string isnull- See Also:
makeKanji(String)
-