wcwidth.api
code-point-to-string
(code-point-to-string code-point)
Returns the string representation of any Unicode code-point†.
This is useful because Clojure/Java string literals only support escape
sequences for code-points in the basic plane, which involves manual conversion
of all supplementary code-points into pairs of escapes.
†a character or integer, but note that Java/Clojure characters are limited to
the Unicode basic plane (first 0xFFFF code-points) for historical reasons
code-points-to-string
(code-points-to-string code-points)
Returns a string made up of all of the given code-points†
†a sequence of characters or integers, but note that Java/Clojure characters
are limited to the Unicode basic plane (first 0xFFFF code-points) for
historical reasons
combining?
(combining? code-point)
Is code-point† a combining character?
†a character or integer, but note that Java/Clojure characters are limited to
the Unicode basic plane (first 0xFFFF code-points) for historical reasons
display-width
(display-width s)
(display-width s & {:keys [ignore-ansi?], :or {ignore-ansi? false}})
Returns the number of columns needed to display String s, but deviates from
POSIX wcswidth behaviour in some key ways i.e. non-printing characters are
considered 0 width (instead of causing the entire result to be -1), and ANSI
escape sequences are (by default) also considered zero width.
For most use cases, this function is generally more useful than wcswidth,
despite not adhering to POSIX.
non-printing?
(non-printing? code-point)
Is code-point† a non-printing character?
†a character or integer, but note that Java/Clojure characters are limited to
the Unicode basic plane (first 0xFFFF code-points) for historical reasons
null?
(null? code-point)
Is code-point† a null character?
†a character or integer, but note that Java/Clojure characters are limited to
the Unicode basic plane (first 0xFFFF code-points) for historical reasons
remove-ansi
(remove-ansi s)
Strips all ANSI escape sequences from the given String.
string-to-code-points
(string-to-code-points s)
Returns all of the Unicode code-points in s, as a sequence of integers.
wcswidth
(wcswidth s)
Returns the number of columns needed to represent String s. If a non-printing
code-point occurs in s, -1 is returned.
wcwidth
(wcwidth code-point)
Returns the number of columns needed to represent the code-point†. If
code-point is a printable character, the value is at least 0. If code-point is
a null character, the value is 0. Otherwise, -1 is returned (the code-point is
non-printing).
†a character or integer, but note that Java/Clojure characters are limited to
the Unicode basic plane (first 0xFFFF code-points) for historical reasons
wide?
(wide? code-point)
Is code-point† in the East Asian Wide (W), East Asian Full-width (F), or
other wide character (e.g. emoji) category?
†a character or integer, but note that Java/Clojure characters are limited to
the Unicode basic plane (first 0xFFFF code-points) for historical reasons