CODEPOINT()

All functions > STRING > CODEPOINT()

Returns the Unicode code point of the first character in a 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

  • Only the first character of the input string is considered
  • For multi-byte Unicode characters, returns the full Unicode code point of that character
  • Returns NULL if the input is NULL (use NULL(VARCHAR); bare NULL is untyped and fails inference)
  • Returns 0 for empty strings
  • This is the inverse operation of CHR

Examples

FeatureQL
SELECT
    f1 := CODEPOINT('A'), -- ASCII value of 'A'
    f2 := CODEPOINT('a'), -- ASCII value of 'a'
    f3 := CODEPOINT('0'), -- ASCII value of '0'
    f4 := CODEPOINT('ABC'), -- Only first character is considered
    f5 := CODEPOINT('€'), -- Unicode code point for Euro symbol
    f6 := CODEPOINT('😀'), -- Unicode code point for emoji
    f7 := CODEPOINT(NULL(VARCHAR)) -- NULL string yields NULL
;
Result
f1 BIGINTf2 BIGINTf3 BIGINTf4 BIGINTf5 BIGINTf6 BIGINTf7 BIGINT
659748658364128512NULL

Last update at: 2026/05/26 17:22:09