The public API of clj-wcwidth
.
The public API of [`clj-wcwidth`](https://github.com/pmonks/clj-wcwidth).
(code-point-to-string code-point)
Returns the String
representation of any Unicode code-point
<sup>†</sup>.
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 separately (tedious and error
prone).
<sup>†</sup>a Character
or int
, but note that Java/Clojure characters are
limited to the Unicode basic plane (first 0xFFFF code-points) for historical
reasons
Returns the `String` representation of any Unicode `code-point`<sup>†</sup>. 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](https://en.wikipedia.org/wiki/UTF-16#Code_points_from_U+010000_to_U+10FFFF), and then each element in the pair escaped separately (tedious and error prone). <sup>†</sup>a `Character` or `int`, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for [historical reasons](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
(code-points-to-string code-points)
Returns a String
made up of all of the given code-points
<sup>†</sup>
<sup>†</sup>a sequence of Character
s or int
s, but note that Java/Clojure
characters are limited to the Unicode basic plane (first 0xFFFF code-points)
for historical reasons
Returns a `String` made up of all of the given `code-points`<sup>†</sup> <sup>†</sup>a sequence of `Character`s or `int`s, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for [historical reasons](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
(combining? code-point)
Is code-point
<sup>†</sup> a combining character?
<sup>†</sup>a Character
or int
, but note that Java/Clojure characters are
limited to the Unicode basic plane (first 0xFFFF code-points) for historical
reasons
Is `code-point`<sup>†</sup> a combining character? <sup>†</sup>a `Character` or `int`, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for [historical reasons](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
(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.
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.
(grapheme-clusters s)
Returns the Unicode grapheme clusters in s
, as a sequence of String
s.
Returns nil
when s
is nil
.
Notes:
BreakIterator
class when available, falling back on the JDK's lower quality BreakIterator
class otherwiseReturns the Unicode grapheme clusters in `s`, as a sequence of `String`s. Returns `nil` when `s` is `nil`. Notes: * Will use [ICU4J's `BreakIterator`](https://unicode-org.github.io/icu-docs/apidoc/released/icu4j/com/ibm/icu/text/BreakIterator.html) class when available, falling back on the [JDK's lower quality `BreakIterator`](https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/text/BreakIterator.html) class otherwise
Which implementation is in use for finding grapheme clusters? A keyword with one of these values:
:icu4j
:jdk
Which implementation is in use for finding grapheme clusters? A keyword with one of these values: * `:icu4j` * `:jdk`
(non-printing? code-point)
Is code-point
<sup>†</sup> a non-printing character?
<sup>†</sup>a Character
or int
, but note that Java/Clojure characters are
limited to the Unicode basic plane (first 0xFFFF code-points) for historical
reasons
Is `code-point`<sup>†</sup> a non-printing character? <sup>†</sup>a `Character` or `int`, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for [historical reasons](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
(null? code-point)
Is code-point
<sup>†</sup> a null character?
<sup>†</sup>a Character
or int
, but note that Java/Clojure characters are
limited to the Unicode basic plane (first 0xFFFF code-points) for historical
reasons
Is `code-point`<sup>†</sup> a null character? <sup>†</sup>a `Character` or `int`, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for [historical reasons](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
(remove-ansi s)
Strips all ANSI escape sequences from s
(a String
). Returns nil
if s
is nil
.
Strips all ANSI escape sequences from `s` (a `String`). Returns `nil` if `s` is `nil`.
(string-to-code-points s)
Returns all of the Unicode code-points in s
(a String
), as a sequence of
int
s.
Returns all of the Unicode code-points in `s` (a `String`), as a sequence of `int`s.
(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).
If s
is nil
, 0
is returned.
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). If `s` is `nil`, `0` is returned.
(wcwidth code-point)
Returns the number of columns needed to represent the code-point
<sup>†</sup>, based on these rules:
0
, 1
, or 2
0
-1
nil
: 0
<sup>†</sup>a Character
or int
, but note that Java/Clojure characters are
limited to the Unicode basic plane (first 0xFFFF code-points) for historical
reasons
Returns the number of columns needed to represent the `code-point` <sup>†</sup>, based on these rules: * Printable: `0`, `1`, or `2` * Null character: `0` * Non-printing: `-1` * `nil`: `0` <sup>†</sup>a `Character` or `int`, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for [historical reasons](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
(wide? code-point)
Is code-point
<sup>†</sup> in the East Asian Wide (W), East Asian Full-width
(F), or other wide character (e.g. emoji) category?
<sup>†</sup>a Character
or int
, but note that Java/Clojure characters are
limited to the Unicode basic plane (first 0xFFFF code-points) for historical
reasons
Is `code-point`<sup>†</sup> in the East Asian Wide (W), East Asian Full-width (F), or other wide character (e.g. emoji) category? <sup>†</sup>a `Character` or `int`, but note that Java/Clojure characters are limited to the Unicode basic plane (first 0xFFFF code-points) for [historical reasons](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
cljdoc builds & hosts documentation for Clojure/Script libraries
Ctrl+k | Jump to recent docs |
← | Move to previous article |
→ | Move to next article |
Ctrl+/ | Jump to the search field |