Class Punycode


  • public final class Punycode
    extends java.lang.Object
    Ported code from ICU punycode.c
    • Constructor Summary

      Constructors 
      Constructor Description
      Punycode()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static int adaptBias​(int delta, int length, boolean firstTime)  
      private static char asciiCaseMap​(char b, boolean uppercase)  
      static java.lang.StringBuilder decode​(java.lang.CharSequence src, boolean[] caseFlags)
      Converts Punycode to Unicode.
      private static 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 java.lang.StringBuilder encode​(java.lang.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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Punycode

        public Punycode()
    • Method Detail

      • 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 java.lang.StringBuilder encode​(java.lang.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 java.lang.StringBuilder decode​(java.lang.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