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'); ?
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 6 years ago.
I'm listing the customers names on my webpage with PHP retrieving data from MySql, but some of them are called José, João, but when I echo the result on the page, it shows Jos� and Jo�o.
The collations of the tables are all on utf8_general_ci what can I possibly be doing wrong??
This appears to be a browser display issue. Try adding the following line between the head tags of your html document.
<meta charset="UTF-8">
This should solve the problem. If not, leave a comment And I'll help you resolve it.
Your page source code should also be utf-8 encoded, to display UTF8 encoded characters, otherwise your browser tries to apply character encoding from http header to you strings.
use
echo utf8_encode($yourstring);
but, also is recommended to set in html
<meta charset="UTF-8">
and consider to create database with utf-8 encoding and collation spanish or whatever it have this kind of characters
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)
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.
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 :)