This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 9 years ago.
I am trying to store the characters ♯ and ♭ in a mySQL database, but ♯ gets stored as A♯ and ♭ as Bâ™
In the HTML, I have used ♯ and ♯ and both render fine in the browser, but neither is being stored correctly.
I have tried UTF-8 and UTF-16 character sets for both the PHP page and for the field where the values are being stored and I get the same result.
I'm not very familiar with character sets, so maybe I should be using something other that UTF-8 or -16 or maybe I'm missing something else entirely?
did you try to use varbinary / binary.
If you have again the problem, check your DB charset, table charset, col charset, php script charset.
If you have the problem after, you can use base64_(en|de)code :)
Related
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 6 years ago.
I have a form that needs to accept special font characters and write them to the database table. I believe the encoding is set correctly at the page/form level but when the field is written to the database the characters get changed to some other encoding. Other SO answers seem to indicate setting encoding to UTF-8 is the answer, which i've done.
Now, if I copy paste the characters below, direct to the database table, it holds them just fine as shown. Its only when I write it to the table from the form or when i retrieve it for display in web page.
Example characters: ⓄⒼקร
The web page is set as: <meta charset="utf-8">
The form tag includes attribute: accept-charset="UTF-8"
Php just before the INSERT has: $_POST['tag']=utf8_encode($_POST['tag']);
I have not had to write/encode those types of font/special characters before, so what am i doing wrong here?
Do not use the PHP utf8_encode() or utf8_decode() functions.
Despite their promising-sounding names, what these functions actually do is mangle UTF8 text -- either by double-encoding UTF8 text, or by converting text to the ISO8859-1 encoding and replacing characters outside the Latin-1 range with question marks.
Remove the call to utf8_encode(), make sure your database table has the proper encoding (CHARACTER SET = utf8mb4), and you should be fine.
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 8 years ago.
I displayed some Russian words on HTML and it showed like following.
Полный кадр
The result is:
Полный кадр
I tried to convert the original string to UTF8 and displayed in HTML. I showed like above.
Some information:
store field collation: latin1_swedish_ci
The sql result is :
ÐолнÑй кадÑ
I queried the database and get the value. And then convert to utf8:
mb_convert_encoding($value, 'utf-8', 'windows-1251');
Could you please take a look at this link. Someone fixed it:
http://stackoverflow.com/questions/13765242/need-help-determining-encoding-of-the-text
The problem is I'm rebuilding a website. Some data is from old website. And I cannot input it manually because It's a lot. So I wrote a php script to get data from the old website and inserted to my new website. The old website display russian in HTML perfectly. But I didn't code it, and I cannot see his code.
I already check the data between old table and new table. It's the same.
You should change collation for your table to e.g. utf8_unicode_ci, or koir... for Russian, so you can get the right result. latin_swedish does not support Cyrillic characters.
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 8 years ago.
I'm building a php search page for a photo gallery to pull data with Chinese characters from MySQL.
I've done the following:
1. setting webpage to utf-8 encoding meta http-equiv="content-type" content="text/html";charset="utf-8"
2. ensure that the collation for mysql db and data itself is utf8_general_ci
3. set chrome encoding to utf-8.
But when I put in a positive search string to pull data with Chinese characters, they always come up as ???
I've checked my php array raw output and it is also ??? which leads me to believe there is something wrong at my database end. But I need to add is my gallery page (where the search box is embedded) displays the Chinese characters correctly from the same database.
Have you also set $mysqli->set_charset('utf8'); ?
This question already has answers here:
UTF-8 all the way through
(13 answers)
Insert into a table which has a dash in the name
(4 answers)
Closed 8 years ago.
While inserting data "Jack - Jill" in mysql db, it saving as "Jack †Jill“, my problem is when i tried to display the string in page its showing like "Jack �€� Jill", i am just botherd to display the string properly like "Jack - Jill", i tried have proper charactersets but not much of luck.
make sure you specify the charset used by your page to the database (and all its tables), and the other way around. i.e.:
Give your page a metatag and the script witing to the database a line that either validates that the charset is UTF-8 (example charset), or that it converts the chaarset to UTF-8
and give your database the same property, that it saves and reads data as UTF-8 (i use PHPMyAdmin, if you use such GUI tools too, its just a checkbox away).
hope i pointed you into the right direction
This question already has answers here:
UTF-8 all the way through
(13 answers)
Closed 9 years ago.
This might be a dummy question, but I'm a little lost in it.
How are Arabic questions exactly stored in a database ?
Let's take ب, if I insert that directly in the DB it becomes ?. Not good.
If I use a form (and php script) and store it as UTF-8, it is stored like ب. I can read it out and print it out, all good.
So my question is, are Arabic (and Japanese,...) letters always stored likes this in a mysql database ب ? Or should I change a setting somewhere and it should look like ب when I'm browsing the database?
It's just to define the length of my rows (varchars/chars) in the database...
DB set to utf8_general
Site fully UTF8
If you try to store a UTF-8 encoded character and it becomes ?, this means MySQL did not understand or support the encoding in which you sent the character. The column needs to be set to store utf8 data (better utf8mb4 if supported) and the connection encoding needs to be set to the correct encoding to inform MySQL in what encoding you're sending data to it.
If you get HTML entities from a form submission, this means the browser tried to send data in an encoding which did not support that particular character; therefore it had to fall back on HTML entities to encode the character. You need to set the encoding declarations correctly to tell the browser it should send UTF-8 encoded text to the server.
See Handling Unicode Front To Back In A Web App and/or UTF-8 all the way through for how to do all this.