Home > Software engineering >  What encoding to use for the special name in mysql
What encoding to use for the special name in mysql

Time:12-04

i have this name: éššede á I have in mysql but i need search great encoding for this (ASCII, latin1) ?

Because i search where this id from php and not working, problem is characters: (éšš á) from id: éššede á

Thanks

CodePudding user response:

Lots of CHARACTER SETs can handle those characters:

                         CHARACTER SET        Hex
                    binary, utf8mb4, utf8  C3A9C5A1C5A1C3A1
                           cp1250, latin1  E99A9AE1
                                    cp852  82E7E7A0
                            eucjpms, ujis  8FABB18FABDE8FABDE8FABA1
                                  gb18030  A8A68130943881309438A8A2
                                      hp8  C5ECECC4
                                  keybcs2  82A8A8A0
                                   latin2  E9B9B9E1
                                    macce  8EE4E487

latin7 almost works, but not for á.

uft8mb4 is strongly recommended; it handles "everything".

CodePudding user response:

you should switch to uft8mb4

But latin1 with a correct collation does also the trick

Basically you need also the correct connection string with the same settings of your table

CREATE TABLE name(name1 varchar(10))
CREATE TABLE name_1(name1 varchar(10)) CHARACTER SET latin1 COLLATE latin1_danish_ci;
SHOW CREATE TABLE name
Table | Create Table                                                                                                                     
:---- | :--------------------------------------------------------------------------------------------------------------------------------
name  | CREATE TABLE `name` (<br>  `name1` varchar(10) DEFAULT NULL<br>) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
INSERT INTO name VALUES ('éššede á')
SELECT * FROM name WHERE name1 LIKE 'éššede á'
| name1        |
| :----------- |
| éššede á |
INSERT INTO name_1 VALUES ('éššede á')
SELECT * FROM name_1 WHERE name1 LIKE 'éššede á'
| name1        |
| :----------- |
| éššede á |

db<>fiddle here

  • Related