CHAR()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a string consisting of characters defined by the given code values.
USAGE
CHAR(expr[, expr] ... [USING charset])
Argument Name | Description |
---|---|
| One or more comma-separated integer expressions |
| The optional |
DETAILS
CHAR()
is a string function that returns a string consisting of characters represented by the code values of the comma-separated integers supplied as the arguments.
The mapping of integers to characters can be found in standard ASCII, UNICODE, etc. charts.
The return value is a binary string by default.
The optional USING
clause may be used to generate a string in a specific character set.
The number of result bytes generated for each input value depends on the character set and how large the input values are. An input value larger than 255 will always result in multiple bytes.
Any NULL
values in the input arguments are ignored.
EXAMPLES
SELECT CHAR(72, NULL, 105, 33);
+-------------------------+
| CHAR(72, NULL, 105, 33) |
+-------------------------+
| Hi! |
+-------------------------+
SELECT CHAR(64, 76);
+--------------+
| CHAR(64, 76) |
+--------------+
| @L |
+--------------+
SELECT CHAR(77, '97', 114, 105, 97, '68', 66);
+----------------------------------------+
| CHAR(77, '97', 114, 105, 97, '68', 66) |
+----------------------------------------+
| MariaDB |
+----------------------------------------+
SELECT HEX(CHAR(1,1,0)) AS Ex1,
HEX(CHAR(260)) AS Ex2;
+--------+------+
| Ex1 | Ex2 |
+--------+------+
| 010100 | 0104 |
+--------+------+