Skip to content
FutureBlitz

    Install

    Import std.text.char

    Char

    std.text.char

    extend

    Extend Char

    A Char's code, what kind of character it is, and its case.

    std/text/char.fb, line 16

    • Public Property Code: Int property #

      Its code point, from 0 to 0x10FFFF.

    • Public Property Utf8Length: Int property #

      How many bytes it takes in UTF-8: 1 to 4.

    • Public Static Method From(code: Int): Char? static method #

      The Char of a code point, or Null for one that isn't a Unicode scalar value: below 0, past 0x10FFFF, or a surrogate, 0xD800 to 0xDFFF.

      Examples

      Expect('A'.Code == 65)
      Expect(Char.From(0x1F600)?.Utf8Length == 4)
      Expect(Char.From(0xD800) == Null)
    • Public Method IsLetter(): Bool method #

      Whether it's a letter, of any case or none, as in "é", "ж", or "中".

      Examples

      Expect('a'.IsLetter() && !'7'.IsLetter())
      Expect('7'.IsDigit() && ' '.IsWhitespace())
      Expect('é'.ToUpper() == 'É')
    • Public Method IsDigit(): Bool method #

      Whether it's a decimal digit, of any script, like "7" or "٣".

    • Public Method IsNumber(): Bool method #

      Whether it's a number of any kind: a decimal digit, a letter like a Roman numeral, or another like "½".

    • Public Method IsLetterOrDigit(): Bool method #

      Whether it's a letter or a decimal digit.

    • Public Method IsUpper(): Bool method #

      Whether it's an uppercase letter.

    • Public Method IsLower(): Bool method #

      Whether it's a lowercase letter.

    • Public Method IsPunctuation(): Bool method #

      Whether it's punctuation, like "," or "¿".

    • Public Method IsSymbol(): Bool method #

      Whether it's a symbol, like "+", "$", or "©".

    • Public Method IsControl(): Bool method #

      Whether it's a control character, like a tab or a line break.

    • Public Method IsWhitespace(): Bool method #

      Whether it's whitespace, as Unicode's White_Space has it: a space of any width, a tab, a line or paragraph break, and the like.

    • Public Method IsAscii(): Bool method #

      Whether it's ASCII, U+0000 to U+007F.

    • Public Method ToUpper(): Char method #

      Its own uppercase, or itself when it has none. A String's ToUpper turns "ß" into "SS", which one Char can't hold.

    • Public Method ToLower(): Char method #

      Its own lowercase, or itself when it has none.

    Report an issue with this page or with FutureBlitz on GitHub.