Comments - Setting Character Sets and Collations

3 years, 10 months ago Morten Berg

I have problem with comparing unicode strings.

: mysql --default-character-set=utf8mb4 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 57932
Server version: 10.0.29-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

MariaDB [(none)]> SET character_set_server='utf8mb4';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> select 'var'='vår';
| 'var'='vår'  |
|            1 |
1 row in set (0.00 sec)

Why is this true?

3 years, 10 months ago Ian Gilfillan

These evaluate as equivalent in the default collation, utf8mb4_general_ci

If you change the collation to utf8mb4_bin (in this example just for the connection), this will not be the case:

SET collation_connection = 'utf8mb4_bin';

select 'var'='vår';
| 'var'='vår'  |
|            0 |
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.