Elm Exactly

Basis entryChar.toCode

A value of Char. Its type is in Section C.4 Further Data Types.

Static basis

toCode ↦ (Char→Int,v)\begin{array}{|rcl|}\hline \href{/standard/basis/Char/toCode}{\kw{toCode}} {\ }& \mapsto {\ }& (\tChar \rightarrow \tInt, \isv)\\\hline\end{array}
Figure 41: Static Interfaces of Maybe, Result, String, Char, Array and Bytes

Dynamic basis

var or con ↦ varitytoCode, fromCode ↦ basic value1\begin{array}{|rclc|}\hline \var\ \text{or}\ \con {\ }& \mapsto {\ }& v {\qquad}& \arity\\\hline \href{/standard/basis/Char/toCode}{\kw{toCode}},\ \href{/standard/basis/Char/fromCode}{\kw{fromCode}} {\ }& \mapsto {\ }& \text{basic value} {\qquad}& 1\\\hline\end{array}
Figure 47: Dynamic VE\VE of the Other Modules of ME0\ME_0

Its APPLY

APPLY(Char.toCode,ch) = {code(ch)}\begin{array}{rcll} \APPLY(\kw{Char.toCode},\dbch) {\ }& = {\ }& \{\dbcode(\dbch)\} {\quad}& \end{array}
Figure 53: APPLY\APPLY on Conversions
Read it in its chapter·Permanent address: /standard/basis/Char/toCode

Tests (11)

  • elm / AstralCharLiteralTest
    A `Char` literal above U+FFFF has its full code point: `'\u{1F600}'` is 128512, and is the same character as `'😀'` written directly.
  • elm / CharAstralClosureCaptureTest
    An astral `Char` (code point above 0xFFFF) referred to by a lambda, or supplied as the first argument of a partially applied function, keeps its code point when the function is called later.
  • elm / CharAstralCustomFieldTest
    An astral `Char` (code point above 0xFFFF) stored in a custom-type constructor's field keeps its code point when read back by pattern matching.
  • elm / CharAstralRecordFieldTest
    An astral `Char` (code point above 0xFFFF) in a record field keeps its code point, next to an `Int` field and after a record update, and a record holding one is equal to a record literal with the same fields.
  • elm / CharAstralTupleTest
    An astral `Char` (code point above 0xFFFF) in a pair and in a 3-tuple keeps its code point when read back with a tuple pattern, in a function's argument and in a destructuring `let`. How `Debug.log` prints such tuples is checked by `CharAstralTupleShowTest`.
  • elm / CharUnicodeTest
    `Char.toCode` of non-ASCII character literals written as `\u{...}` escapes gives their code points: 955 for U+03BB and 8364 for U+20AC.
  • elm-core / CharAstralCodeTest
    `Char.fromCode` and `Char.toCode` round-trip Unicode code points, including astral ones (above 0xFFFF) and the largest, 0x10FFFF.
  • elm-core / CharToCodeTest
    `Char.toCode` gives the code points 65, 97 and 48 for `'A'`, `'a'` and `'0'`.
  • elm-core / CharToCodeThroughFunctionTest
    `Char.toCode` of a character returned from a top-level function, here an identity function applied to `'A'`, gives 65.
  • elm-core / CoreIssue1150CharToCodeLoneSurrogateTest
    `Char.toCode` returns NaN, typed as `Int`, for a lone surrogate.
  • elm-core / StandardA53CharOrderTest
    Characters are ordered by their code points.

Discussions

Discuss this basis entry·Search the discussions on GitHub

Discussions are on GitHub; one about this basis entry has [b:Char.toCode] in its title.

A Standard Definition of Elm? (Draft version 0.4) © Rupert Smith. The text is licensed under CC BY 4.0: share and adapt it freely, with credit and a link to the licence.