Class Punycode

java.lang.Object
com.ibm.icu.impl.Punycode

public final class Punycode extends Object
Ported code from ICU punycode.c
  • Field Details

  • 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