On this page:
Char
Char.to_  int
Char.from_  int
Char.upcase
Char.downcase
Char.foldcase
Char.titlecase
Char.is_  alphabetic
Char.is_  lowercase
Char.is_  uppercase
Char.is_  titlecase
Char.is_  numeric
Char.is_  symbolic
Char.is_  punctuation
Char.is_  graphic
Char.is_  whitespace
Char.is_  blank
Char.is_  extended_  pictographic
Char.general_  category
Char.grapheme_  break_  property
Char.grapheme_  step
Char  CI
8.12

6.25 Characters🔗ℹ

A character is Unicode code point.

Characters are comparable, which means that generic operations like < and > work on characters.

annotation

Char

Matches characters.

function

fun Char.to_int(ch :: Char) :: NonnegInt

Returns the Unicode value of a character.

Returns the character corresponding to a Unicode value. The given i must be in the range 0x0 to 0x10FFFF, (inclusive), and not in the range 0xD800 to 0xDFFF (inclusive).

function

fun Char.upcase(ch :: Char) :: Char

 

function

fun Char.downcase(ch :: Char) :: Char

 

function

fun Char.foldcase(ch :: Char) :: Char

 

function

fun Char.titlecase(ch :: Char) :: Char

Unicode case conversions.

Character Unicode classifications:

function

fun Char.grapheme_step(ch :: Char, state :: Int)

  :: (Boolean, Int)

Encodes a state machine for Unicode’s grapheme-cluster specification on a sequence of code points. It accepts a character for the next code point in a sequence, and it returns two values: whether a (single) grapheme cluster has terminated since the most recently reported termination (or the start of the stream), and a new state to be used with Char.grapheme_step and the next character.

A value of 0 for state represents the initial state or a state where no characters are pending toward a new boundary. Thus, if a sequence of characters is exhausted and accumulated state is not 0, then the end of the stream creates one last grapheme-cluster boundary. When Char.grapheme_step produces a true value as its first result and a non-0 value as its second result, then the given ch must be the only character pending toward the next grapheme cluster (by the rules of Unicode grapheme clustering).

The Char.grapheme_step procedure will produce a result for any fixnum state, but the meaning of a non-0 state is specified only in that providing such a state produced by Char.grapheme_step in another call to Char.grapheme_step continues detecting grapheme-cluster boundaries in the sequence.

See also String.grapheme_span and String.grapheme_count.

annotation

CharCI

A veneer for a character that redirects comparable operations like < and > to case-insensitive comparisons, equivalent to using Char.foldcase on each character before comparing.

As always for a veneer, CharCI normally should be used in static mode to help ensure that it has the intended effect.

> "a"[0] < "B"[0]

#false

> ("a"[0] :: CharCI) < ("B"[0] :: CharCI)

#true