Class Unicode

  • All Implemented Interfaces:
    Comparable<Char>, Char, Stringable

    public class Unicode
    extends Object
    implements Char
    Representation of a unicode character. It represents the full 31-but unicode code point, and will expand to the 2 surrogate paired string if necessary.
    • Field Detail

      • NBSP

        public static final Unicode NBSP
        No-break space.
      • LTR_ISOLATE

        public static final Unicode LTR_ISOLATE
        sets base direction to LTR and isolates the embedded content from the surrounding text
      • RTL_ISOLATE

        public static final Unicode RTL_ISOLATE
        ditto, but for RTL
      • FS_ISOLATE

        public static final Unicode FS_ISOLATE
        isolates the content and sets the direction according to the first strongly typed directional character
      • LTR_EMBED

        public static final Unicode LTR_EMBED
        sets base direction to LTR but allows embedded text to interact with surrounding content, so risk of spillover effects
      • RTL_EMBED

        public static final Unicode RTL_EMBED
        ditto, but for RTL
      • LTR_OVERRIDE

        public static final Unicode LTR_OVERRIDE
        overrides the bidirectional algorithm to display characters in memory order, progressing from left to right
      • RTL_OVERRIDE

        public static final Unicode RTL_OVERRIDE
        as previous, but display progresses from right to left
    • Constructor Detail

      • Unicode

        public Unicode​(int cp)
        Create a unicode instance.
        Parameters:
        cp - Character code point.
      • Unicode

        public Unicode​(char ch)
        Create a unicode instance.
        Parameters:
        ch - Unicode character.
    • Method Detail

      • unicode

        public static Unicode unicode​(int cp)
        Create a unicode instance.
        Parameters:
        cp - Code point of unicode character, can be BMP or extended.
        Returns:
        The unicode char.
      • unicode

        public static Unicode unicode​(char ch)
        Create a unicode instance.
        Parameters:
        ch - The unicode character (BMP).
        Returns:
        The unicode char.
      • codepoint

        public int codepoint()
        Description copied from interface: Char
        Unicode codepoint representing this character.
        Specified by:
        codepoint in interface Char
        Returns:
        The 31 bit unsigned unicode code-point, or -1 if not representing a single unicode character.
      • asString

        public String asString()
        Description copied from interface: Stringable
        Make a string representation of the instance value.
        Specified by:
        asString in interface Stringable
        Returns:
        The string representation.
      • printableWidth

        public int printableWidth()
        Description copied from interface: Char
        The number of character spaces taken up by this symbol. Usually 1, but 0 for control sequences, control characters, and 2 for wide symbols like CJK characters.
        Specified by:
        printableWidth in interface Char
        Returns:
        The printable width of the character.
      • length

        public int length()
        Description copied from interface: Char
        Number of utf-16 characters that this character takes up if enclosed in a java string.
        Specified by:
        length in interface Char
        Returns:
        The char count of the character.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object