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->stringclj

(code-point->string code-point)

Returns the String representation of any Unicode code-point<sup>†</sup>, or nil when code-point is nil.

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 UTF-16 code unit in the pair escaped separately (tedious and error prone).

<sup>†</sup>a char or int, but int is usually the better choice, because of historical limitations with Java's char type

Returns the `String` representation of any Unicode `code-point`<sup>†</sup>,
or `nil` when `code-point` is `nil`.

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 UTF-16 code unit in the pair escaped separately (tedious and
error prone).

<sup>†</sup>a `char` or `int`, but `int` is usually the better choice, because
of [historical limitations with Java's `char` type](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
sourceraw docstring

code-point-to-stringcljdeprecated

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

Deprecated. Use code-point->string instead.

Deprecated. Use [[code-point->string]] instead.
sourceraw docstring

code-points->stringclj

(code-points->string code-points)

Returns a String made up of all of the given Unicode code-points<sup>†</sup>, or nil when code-points is nil.

<sup>†</sup>a sequence of chars or ints, but ints are usually the better choice, because of historical limitations with Java's char type

Returns a `String` made up of all of the given Unicode
`code-points`<sup>†</sup>, or `nil` when `code-points` is `nil`.

<sup>†</sup>a sequence of `char`s or `int`s, but `int`s are usually the better
choice, because of [historical limitations with Java's `char` type](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
sourceraw docstring

code-points-to-stringcljdeprecated

(code-points-to-string code-points)

Deprecated. Use code-points->string instead.

Deprecated. Use [[code-points->string]] instead.
sourceraw docstring

combining?clj

(combining? code-point)

Is code-point<sup>†</sup> a combining character?

<sup>†</sup>a char or int, but int is usually the better choice, because of historical limitations with Java's char type

Is `code-point`<sup>†</sup> a [combining character](https://en.wikipedia.org/wiki/Combining_character)?

<sup>†</sup>a `char` or `int`, but `int` is usually the better choice, because
of [historical limitations with Java's `char` type](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 these ways:

  • non-printing characters are considered zero width (instead of causing the entire result to be -1)
  • ANSI escape sequences are (by default, but configurable) also considered zero width

For most use cases, this function is more useful than wcswidth, despite not adhering to POSIX.

Returns 0 when s is nil.

Returns the number of columns needed to display `s` (a `String`), but
deviates from POSIX [[wcswidth]] behaviour in these ways:

* non-printing characters are considered zero width (instead of causing the
  entire result to be `-1`)
* ANSI escape sequences are (by default, but configurable) also considered
  zero width

For most use cases, this function is more useful than [[wcswidth]], despite
not adhering to POSIX.

Returns `0` when `s` is `nil`.
sourceraw docstring

grapheme-clustersclj

(grapheme-clusters s)

Returns the Unicode grapheme clusters (what we tend to think of as "characters") in s as a sequence of Strings, or nil when s is nil.

Notes:

Returns the [Unicode grapheme clusters](https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries)
(what we tend to think of as "characters") in `s` as a sequence of
`String`s, or `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 on the classpath, 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 char or int, but int is usually the better choice, because of historical limitations with Java's char type

Is `code-point`<sup>†</sup> a [non-printing character](https://en.wikipedia.org/wiki/Unicode_control_characters)?

<sup>†</sup>a `char` or `int`, but `int` is usually the better choice, because
of [historical limitations with Java's `char` type](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 char or int, but int is usually the better choice, because of historical limitations with Java's char type

Is `code-point`<sup>†</sup> a [null character](https://en.wikipedia.org/wiki/Null_character)?

<sup>†</sup>a `char` or `int`, but `int` is usually the better choice, because
of [historical limitations with Java's `char` type](https://www.oracle.com/technical-resources/articles/javase/supplementary.html)
sourceraw docstring

re-ansiclj

A regular expression for matching ANSI escape sequences in a larger text. Taken directly from ECMA-48.

A regular expression for matching ANSI escape sequences in a larger text.
Taken directly from [ECMA-48](https://www.ecma-international.org/publications-and-standards/standards/ecma-48/).
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->code-pointsclj

(string->code-points s)

Returns all of the Unicode code points in s (a String), as a sequence of ints, or nil when s is nil.

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

string-to-code-pointscljdeprecated

(string-to-code-points s)

Deprecated. Use string->code-points instead.

Deprecated. Use [[string->code-points]] instead.
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).

Returns 0 when s is nil.

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).

Returns `0` when `s` is `nil`.
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, or nil: 0
  • Non-printing: -1

<sup>†</sup>a char or int, but int is usually the better choice, because of historical limitations with Java's char type

Returns the number of columns needed to represent the `code-point`
<sup>†</sup>, based on these rules:

* Printable: `0`, `1`, or `2`
* Null character, or `nil`: `0`
* Non-printing: `-1`

<sup>†</sup>a `char` or `int`, but `int` is usually the better choice, because
of [historical limitations with Java's `char` type](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 char or int, but int is usually the better choice, because of historical limitations with Java's char type

Is `code-point`<sup>†</sup> in the [East Asian Wide (W), East Asian Full-width
(F), or other wide character (e.g. emoji) category](https://en.wikipedia.org/wiki/Wide_character)?

<sup>†</sup>a `char` or `int`, but `int` is usually the better choice, because
of [historical limitations with Java's `char` type](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