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
| Parameter | Type | Required | Description |
|---|---|---|---|
string | VARCHAR | Yes | A 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); bareNULLis 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 BIGINT | f2 BIGINT | f3 BIGINT | f4 BIGINT | f5 BIGINT | f6 BIGINT |
|---|---|---|---|---|---|
| 65 | 97 | 48 | 8364 | 128512 | NULL |
On this page