Class Unicode

  • All Implemented Interfaces:
    java.lang.Comparable<Char>, Char, net.morimekta.util.Numeric, net.morimekta.util.Stringable

    public class Unicode
    extends java.lang.Object
    implements Char
    Unicode character representation. It represent the full 31-but unicode code point, and will expand to the 2 surrogate paired string if necessary.
    • Constructor Summary

      Constructors 
      Constructor Description
      Unicode​(char ch)  
      Unicode​(int cp)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int asInteger()
      Unicode codepoint representing this character.
      java.lang.String asString()  
      int compareTo​(Char o)  
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      int length()
      Number of utf-16 characters that this character takes up if enclosed in a java string.
      int printableWidth()
      The number of character spaces taken up by this symbol.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NBSP

        public static final Unicode NBSP
        No-break space.
    • Constructor Detail

      • Unicode

        public Unicode​(int cp)
      • Unicode

        public Unicode​(char ch)
    • Method Detail

      • asInteger

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

        public java.lang.String asString()
        Specified by:
        asString in interface net.morimekta.util.Stringable
      • 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.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • compareTo

        public int compareTo​(Char o)
        Specified by:
        compareTo in interface java.lang.Comparable<Char>