1 php mysql encoding character-encoding
我的网站正在使用charset iso 8859 1
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
Run Code Online (Sandbox Code Playgroud)
当用户发布中文字符时,它将被保存到数据库中作为 0 3 2 0; 2 9 0 9; 检索时将输出为中文字符.
我需要将我的网站设置为UTF-8
当用户发布中文字符时,它将被保存为mysql中的一些时髦字符,并且在检索时,某些字符是正确的但有些字符是错误的.
我的问题是,在我设置为UTF-8之后,如何使mysql将文本保存为#2 0 3 2 0; 2 9 0 9; 而不是时髦的角色.
我试图使用htmlentities.它不能正常工作.
我的脚本正在使用
$message = htmlentities(strip_tags(mysql_real_escape_string($_POST['message']),'<img><vid>'));
Run Code Online (Sandbox Code Playgroud)
当它被保存到mysql时,就像这个ä½å¥½当它被检索到显示时就像这样ä½å¥½<----是以前存储在mysql中的时髦字符
在发布之前,我一直看到许多编码相关的问题,所有者应该谷歌一点
一般检查清单:
mysql --default-character-set=utf8mysqli_set_charset到utf-8