Home > database >  how to convert raw utf8mb4_unicode_ci like X'313735313136' to a regular string (utf8) in p
how to convert raw utf8mb4_unicode_ci like X'313735313136' to a regular string (utf8) in p

Time:04-22

This question is about converting a raw utf8mb4_unicode_ci from a .sql to a normal utf-8

My .sql was from a database that had COLLATE utf8mb4_unicode_ci

like this :

(5558,'2019-11-18 18:28:36',X'313735313136','am',''),

in PHP how would I convert this X'313735313136' to a normal utf8 string ?

I tried utf8_decode("\xE18885E18C8D"); but the result is ?8885E18C8D ...

CodePudding user response:

Regardless of the collation of the database, the exported file you are looking at has decoded that and has provided a binhex encoding. I'm not sure what a reasonable value is for that column, but

php -r "print hex2bin('313735313136');"

returns 175116

  • Related