Top Fields Constructors Methods
io.github.kusoroadeolu.clique.internal.utils

public final Class CharWidth

extends Object
Class Inheritance
Annotations
@InternalApi
since:3.2.0
Imports
io.github.kusoroadeolu.clique.internal.documentation.InternalApi, java.util.Arrays

Field Summary

Modifier and TypeField and Description
private static final byte[]
private static final int[]
private static final int[]
private static final int[]
private static final int[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static boolean
inRanges(int codePoint, int[] starts, int[] ends)

private static boolean
isModifier(int cp)

private static boolean
isRegionalIndicator(int codePoint)

Returns true if the code point is a Regional Indicator symbol (U+1F1E6-U+1F1FF).

private static boolean
public static int

Returns:

the total display width in terminal columns
of
(String
the string to measure
s
)

Returns the total display width of a string.

public static int

Returns:

0 for zero-width characters, 2 for wide characters, 1 otherwise
ofCodePoint
(int
the Unicode code point
codePoint
)

Returns the display width (0, 1, or 2) of a Unicode code point.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BMP_WIDTHSback to summary
private static final byte[] BMP_WIDTHS
SUPPLEMENTARY_WIDE_ENDSback to summary
private static final int[] SUPPLEMENTARY_WIDE_ENDS
SUPPLEMENTARY_WIDE_STARTSback to summary
private static final int[] SUPPLEMENTARY_WIDE_STARTS
SUPPLEMENTARY_ZERO_ENDSback to summary
private static final int[] SUPPLEMENTARY_ZERO_ENDS
SUPPLEMENTARY_ZERO_STARTSback to summary
private static final int[] SUPPLEMENTARY_ZERO_STARTS

Constructor Detail

CharWidthback to summary
private CharWidth()

Method Detail

inRangesback to summary
private static boolean inRanges(int codePoint, int[] starts, int[] ends)
isModifierback to summary
private static boolean isModifier(int cp)
isRegionalIndicatorback to summary
private static boolean isRegionalIndicator(int codePoint)

Returns true if the code point is a Regional Indicator symbol (U+1F1E6-U+1F1FF). Regional Indicator pairs form flag emoji.

isTagCharacterback to summary
private static boolean isTagCharacter(int cp)
ofback to summary
public static int of(String s)

Returns the total display width of a string.

Handles grapheme clusters correctly:

  • ZWJ sequences (e.g., ๐Ÿ‘จโ€๐Ÿ‘ฆ): width 2 for the combined glyph
  • Regional Indicator pairs (flags, e.g., ๐Ÿ‡ซ๐Ÿ‡ท): width 2
  • Skin tone modifiers: zero-width (added to base emoji)
Parameters
s:String

the string to measure

Returns:int

the total display width in terminal columns

ofCodePointback to summary
public static int ofCodePoint(int codePoint)

Returns the display width (0, 1, or 2) of a Unicode code point.

Parameters
codePoint:int

the Unicode code point

Returns:int

0 for zero-width characters, 2 for wide characters, 1 otherwise