utf8mb4
This page is part of MariaDB's Documentation.
The parent of this page is: Character Sets for MariaDB Xpand
Topics on this page:
Overview
UTF-8 Unicode (maxlen 4)
DETAILS
Default Collation: utf8mb4_
general_ ci Max Length: 4 bytes
The collation names accepted for this character set are:
EXAMPLES
SELECT TYPEOF(_utf8mb4'Test') AS result1,
TYPEOF(CONVERT('Test' USING utf8mb4)) AS result2\G
*************************** 1. row ***************************
result1: varchar(255) CHARACTER SET utf8 not null
result2: varchar(65535) CHARACTER SET utf8mb4
CREATE TABLE charset_example (
name VARCHAR(32),
description VARCHAR(64) CHARSET utf8mb4
);
SET NAMES utf8;
SET @txt = _utf8"Dji pou magnî do vêre, çoula m' freut nén må.";
INSERT INTO charset_example VALUES
('test 1', CONVERT(@txt USING utf8mb4)),
('test 2', 'A normal string.');
SELECT name,
LENGTH(description) AS bytes,
CHAR_LENGTH(description) AS chars
FROM charset_example;
+--------+-------+-------+
| name | bytes | chars |
+--------+-------+-------+
| test 1 | 50 | 45 |
| test 2 | 16 | 16 |
+--------+-------+-------+
SET SESSION character_set_connection = 'utf8mb4';