- java.lang.Object
-
- net.morimekta.strings.chr.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 Summary
Fields Modifier and Type Field Description static Unicode
FS_ISOLATE
isolates the content and sets the direction according to the first strongly typed directional characterstatic Unicode
LTR_EMBED
sets base direction to LTR but allows embedded text to interact with surrounding content, so risk of spillover effectsstatic Unicode
LTR_ISOLATE
sets base direction to LTR and isolates the embedded content from the surrounding textstatic Unicode
LTR_OVERRIDE
overrides the bidirectional algorithm to display characters in memory order, progressing from left to rightstatic Unicode
NBSP
No-break space.static Unicode
RTL_EMBED
ditto, but for RTLstatic Unicode
RTL_ISOLATE
ditto, but for RTLstatic Unicode
RTL_OVERRIDE
as previous, but display progresses from right to left-
Fields inherited from interface net.morimekta.strings.chr.Char
ABR, ACK, BEL, BS, CAN, CR, DEL, ENQ, EOF, ESC, FF, FS, GS, LF, NAK, NUL, RS, SI, SS, TAB, US, VT, XOFF, XON
-
Fields inherited from interface net.morimekta.strings.Stringable
NULL
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
asString()
Make a string representation of the instance value.int
codepoint()
Unicode codepoint representing this character.int
compareTo(Char o)
boolean
equals(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.String
toString()
static Unicode
unicode(char ch)
Create a unicode instance.static Unicode
unicode(int cp)
Create a unicode instance.
-
-
-
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
-
-
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.
-
asString
public String asString()
Description copied from interface:Stringable
Make a string representation of the instance value.- Specified by:
asString
in interfaceStringable
- 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 interfaceChar
- 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.
-
compareTo
public int compareTo(Char o)
- Specified by:
compareTo
in interfaceComparable<Char>
-
-