Package com.ibm.icu.impl
Class Punycode
java.lang.Object
com.ibm.icu.impl.Punycode
Ported code from ICU punycode.c
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private static final int
private static final int
private static final int
private static final int
private static final char
private static final int
private static final char
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static int
adaptBias
(int delta, int length, boolean firstTime) private static char
asciiCaseMap
(char b, boolean uppercase) static StringBuilder
decode
(CharSequence src, boolean[] caseFlags) Converts Punycode to Unicode.private static final int
decodeDigit
(int cp) private static char
digitToBasic
(int digit, boolean uppercase) digitToBasic() returns the basic code point whose value (when used for representing integers) is d, which must be in the range 0 to BASE-1.static StringBuilder
encode
(CharSequence src, boolean[] caseFlags) Converts Unicode to Punycode.private static boolean
isBasic
(int ch) private static boolean
isBasicUpperCase
(int ch) private static boolean
isSurrogate
(int ch)
-
Field Details
-
BASE
private static final int BASE- See Also:
-
TMIN
private static final int TMIN- See Also:
-
TMAX
private static final int TMAX- See Also:
-
SKEW
private static final int SKEW- See Also:
-
DAMP
private static final int DAMP- See Also:
-
INITIAL_BIAS
private static final int INITIAL_BIAS- See Also:
-
INITIAL_N
private static final int INITIAL_N- See Also:
-
HYPHEN
private static final char HYPHEN- See Also:
-
DELIMITER
private static final char DELIMITER- See Also:
-
ZERO
private static final int ZERO- See Also:
-
SMALL_A
private static final int SMALL_A- See Also:
-
SMALL_Z
private static final int SMALL_Z- See Also:
-
CAPITAL_A
private static final int CAPITAL_A- See Also:
-
CAPITAL_Z
private static final int CAPITAL_Z- See Also:
-
ENCODE_MAX_CODE_UNITS
private static final int ENCODE_MAX_CODE_UNITS- See Also:
-
DECODE_MAX_CHARS
private static final int DECODE_MAX_CHARS- See Also:
-
-
Constructor Details
-
Punycode
public Punycode()
-
-
Method Details
-
adaptBias
private static int adaptBias(int delta, int length, boolean firstTime) -
decodeDigit
private static final int decodeDigit(int cp) - Returns:
- the numeric value of a basic code point (for use in representing integers) in the range 0 to BASE-1, or a negative value if cp is invalid.
-
asciiCaseMap
private static char asciiCaseMap(char b, boolean uppercase) -
digitToBasic
private static char digitToBasic(int digit, boolean uppercase) digitToBasic() returns the basic code point whose value (when used for representing integers) is d, which must be in the range 0 to BASE-1. The lowercase form is used unless the uppercase flag is nonzero, in which case the uppercase form is used. -
encode
public static StringBuilder encode(CharSequence src, boolean[] caseFlags) throws StringPrepParseException Converts Unicode to Punycode. The input string must not contain single, unpaired surrogates. The output will be represented as an array of ASCII code points.- Parameters:
src
- The source of the String Buffer passed.caseFlags
- The boolean array of case flags.- Returns:
- An array of ASCII code points.
- Throws:
StringPrepParseException
-
isBasic
private static boolean isBasic(int ch) -
isBasicUpperCase
private static boolean isBasicUpperCase(int ch) -
isSurrogate
private static boolean isSurrogate(int ch) -
decode
public static StringBuilder decode(CharSequence src, boolean[] caseFlags) throws StringPrepParseException Converts Punycode to Unicode. The Unicode string will be at most as long as the Punycode string.- Parameters:
src
- The source of the string buffer being passed.caseFlags
- The array of boolean case flags.- Returns:
- StringBuilder string.
- Throws:
StringPrepParseException
-