wcwidth.api

code-point-to-string

(code-point-to-string code-point)

Returns the String representation of any Unicode code-point.

One of the ways this is useful is because Clojure/Java String literals only support escape sequences (i.e. "\uXXXX") for code-points in the basic plane; code points in the supplementary planes must be manually converted into their UTF-16 surrogate pair, and then each element in the pair escaped (tedious and error prone).

a Character or int, 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 ints, 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 int, 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 s (a String), 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 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 int, 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 int, 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 s (a String).

string-to-code-points

(string-to-code-points s)

Returns all of the Unicode code-points in s (a String), as a sequence of ints.

wcswidth

(wcswidth s)

Returns the number of columns needed to represent s (a String). If a non-printing code-point occurs in s, -1 is returned (as defined in POSIX).

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 int, 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 int, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for historical reasons