CODEPOINT()

All functions > STRING > CODEPOINT()

Returns the Unicode code point of a one-character string.

Signatures

Returns: The Unicode code point of the first character

CODEPOINT(string: VARCHAR) → BIGINT
sql
ParameterTypeRequiredDescription
stringVARCHARYesA VARCHAR input containing the character to convert

Notes

  • The string must be exactly one character. A literal of any other length is refused
  • For a multi-byte Unicode character, returns that character's code point
  • Returns NULL if the input is NULL (use NULL(VARCHAR); bare NULL is untyped and fails inference)
  • This is the inverse operation of CHR

Examples

FeatureQL
RETURN
    -- ASCII value of 'A'
    f1 := CODEPOINT('A'),
    -- ASCII value of 'a'
    f2 := CODEPOINT('a'),
    -- ASCII value of '0'
    f3 := CODEPOINT('0'),
    -- Unicode code point for Euro symbol
    f4 := CODEPOINT('€'),
    -- Unicode code point for emoji
    f5 := CODEPOINT('😀'),
    -- NULL string yields NULL
    f6 := CODEPOINT(NULL::VARCHAR)
;
Result
f1 BIGINTf2 BIGINTf3 BIGINTf4 BIGINTf5 BIGINTf6 BIGINT
6597488364128512NULL