Liking cljdoc? Tell your friends :D

wcwidth.api

The public API of clj-wcwidth.

The public API of [`clj-wcwidth`](https://github.com/pmonks/clj-wcwidth).
raw docstring

code-point-to-stringclj

(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)
sourceraw docstring

code-points-to-stringclj

(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 Characters or ints, 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)
sourceraw docstring

combining?clj

(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)
sourceraw docstring

display-widthclj

(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.
sourceraw docstring

grapheme-clustersclj

(grapheme-clusters s)

Returns the Unicode grapheme clusters in s, as a sequence of Strings. Returns nil when s is nil.

Notes:

Returns 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
sourceraw docstring

grapheme-clusters-implclj

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`
sourceraw docstring

non-printing?clj

(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)
sourceraw docstring

null?clj

(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)
sourceraw docstring

remove-ansiclj

(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`.
sourceraw docstring

string-to-code-pointsclj

(string-to-code-points s)

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

Returns all of the Unicode code-points in `s` (a `String`), as a sequence of
`int`s.
sourceraw docstring

wcswidthclj

(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.
sourceraw docstring

wcwidthclj

(wcwidth code-point)

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

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)
sourceraw docstring

wide?clj

(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)
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close