Categories:

String & binary functions (General)

UNICODEยถ

Returns the Unicode code point for the first Unicode character in a string. If the string is empty, a value of 0 is returned.

See also:

Syntaxยถ

UNICODE( <input> )
Copy

Argumentsยถ

input

The string for which the Unicode code point for the first character in the string is returned.

Examplesยถ

This example demonstrates the function behavior for single ASCII and Unicode characters, as well as special cases, such as multi-character strings, empty strings, and NULL values. It also demonstrates how the UNICODE and CHAR functions interact:

SELECT column1, UNICODE(column1), CHAR(UNICODE(column1))
FROM values('a'), ('\u2744'), ('cde'), (''), (null);

+---------+------------------+------------------------+
| COLUMN1 | UNICODE(COLUMN1) | CHAR(UNICODE(COLUMN1)) |
|---------+------------------+------------------------|
| a       |               97 | a                      |
| โ„       |            10052 | โ„                      |
| cde     |               99 | c                      |
|         |                0 |                        |
| NULL    |             NULL | NULL                   |
+---------+------------------+------------------------+
Copy