I'm trying to change my encoding to utf-8, below is what I have so far.
Table Charset
mbstring installed
extension=php_mbstring.dll
mbstring configured in php.ini
mbstring.language = Neutral
mbstring.internal_encoding = UTF-8
mbstring.encoding_translation = On /*updated it to mbstring.encoding_translation = 0*/
mbstring.http_input = auto /*updated it to mbstring.http_input = pass*/
mbstring.http_output = UTF-8 /*updated it to mbstring.http_output = pass*/
mbstring.detect_order = auto
mbstring.substitute_character
default_charset = UTF-8
mbstring.func_overload = 7
Header
header('Content-type: text/html; charset=UTF-8');
HTML meta tag
<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />
HTML CODE
<label for="article_body_pun">Article (Foreign): </label>
<textarea cols="100" rows="10" name="article_body_pun"></textarea><br />
PHP
$article_body_pun = $_REQUEST['article_body_pun'];
SQL
$insert_article = "INSERT INTO articles(article_body_pun)
VALUES ('{$article_body_pun}'')";
PHP to insert
$article_query = mysqli_query($connectDB, $insert_article);
Data that should be stored -> 汉语
Original Data stored
汉è¯Â
Upon adding mysqli_set_charset($connectDB, "utf8");
as suggested by @Pekka 웃, output became (commented below as well)
æ±è¯
after some troubleshooting, data partially stored correctly.
�?语
tried checking the charset by mb_detect_encoding
, and getting UTF-8
on the results pulled.
and upon checking the charset in firefox.
That seems to be correct, but still getting question marks on some characters. Any further suggestions to make this work?
I was able to fix the problem with help of a friend, the data was not inserted correctly from my HTML form to Database. Seems like my mbstring configurations were causing the problem, had to update the following:
so the values are just reverted back to default and it worked perfectly.
Thanks to @Pekka 웃 and @Willem for their help.