php – 表已经是utf8字符集,仍然在某些字符中出现问号
作者:互联网
我正在尝试将我的编码更改为utf-8,下面是我到目前为止所做的.
表Charset
已安装mbstring
extension=php_mbstring.dll
在php.ini中配置的mbstring
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('Content-type: text/html; charset=UTF-8');
HTML元标记
<meta http-equiv="Content-type" value="text/html; charset=UTF-8" />
HTML代码
<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要插入
$article_query = mysqli_query($connectDB, $insert_article);
应存储的数据 – >汉语
存储原始数据
汉è¯Â
添加mysqli_set_charset($connectDB,“utf8”);正如@Pekka웃所建议的那样,输出成为(以下评论)
æ±è¯
经过一些故障排除后,数据部分正确存储
�?语
尝试通过mb_detect_encoding检查charset,并在结果上获取UTF-8.
并检查firefox中的charset.
这似乎是正确的,但仍然在某些角色上出现问号.任何进一步的建议,使这项工作?
解决方法:
你快到了:确保mySQL连接也编码为UTF-8.
查看UTF-8 all the way through了解详情.
标签:php,mysql,utf-8,character-encoding,mbstring 来源: https://codeday.me/bug/20190708/1407064.html