Package com.tonic.vellum
Class CharWidth
- java.lang.Object
-
- com.tonic.vellum.CharWidth
-
public final class CharWidth extends java.lang.ObjectTerminal display width of characters and code points: 0 for zero-width, 2 for East Asian wide characters and common emoji, 1 otherwise. Best-effort per code point; not grapheme-cluster aware.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intof(char c)Returns the display width of a BMP character.static intof(int cp)Returns the display width of a Unicode code point.static intwidth(java.lang.CharSequence text)Returns the total display width of a sequence (sum of its code points' widths).
-
-
-
Method Detail
-
of
public static int of(char c)
Returns the display width of a BMP character.- Parameters:
c- the character to measure- Returns:
- the display width (0, 1, or 2)
-
width
public static int width(java.lang.CharSequence text)
Returns the total display width of a sequence (sum of its code points' widths).- Parameters:
text- the sequence to measure- Returns:
- the total display width
-
of
public static int of(int cp)
Returns the display width of a Unicode code point.- Parameters:
cp- the code point to measure- Returns:
- the display width (0, 1, or 2)
-
-