With this query:
UPDATE `arg`.`arg_currency` SET `symbol` = '𐀤' WHERE `arg_currency`.`id` =2 LIMIT 1 ;
I get this error:
Warning: #1366 Incorrect string value: '\xF0\x90\x80\xA4' for column 'symbol' at row 1
The column symbol
was a CHAR(1)
utf8_roman_ci
, but I've both tried to change the collation to _general and to _unicode, and the chars to 4, but I've still got the same error.
What am I doing wrong?
(I've both tried to insert it via custom php code and via phpmyadmin)
By using MySQL Workbench Alter the table of that column you want to insert unicode into. Change Collation of that column to utf8-default collation . Apply the setting and you are good to go to insert unicode.
MySQL supports multiple Unicode character sets: utf8mb4 : A UTF-8 encoding of the Unicode character set using one to four bytes per character. utf8mb3 : A UTF-8 encoding of the Unicode character set using one to three bytes per character.
The MySQL ENCODE() function is used for encoding a plain text string. The MySQL ENCODE() function returns a binary string which of the same size of the plain text string. The MySQL DECODE() function returns empty strings if the string passed is an empty string.
As @CarpeNoctumDC points out, this question explains the problem:
MySQL don't want to store unicode character
MySQL only supports characters from the basic multilingual plane (0x0000 - 0xFFFF).
Your character is out if this plane.
In your case, I would work around it by storing the character as a numeric entity. no, it doesn't.htmlentities()
with the UTF-8 encoding specified should be able to entity it, for example.
This function in the User Contributed Notes of the PHP manual works for me: It converts the character into a numeric entity.
echo utf8tohtml("𐀤", true); // echoes 𐀤
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With