在UTF-8中显示法语重音字符的问题 [英] Problems displaying French accented characters in UTF-8

查看:112
本文介绍了在UTF-8中显示法语重音字符的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个建立在CakePHP上的法语网站。我尝试过多种功能来尝试将文本转换为UTF-8并正确显示,但迄今没有成功,任何重音字母都将显示为带有问号的黑色钻石。当我将浏览器中的字符集更改为ISO-8859-1时,它们会正确显示,但我希望使UTF-8的站点符合要求。我使用过:



html_entity_decode($ string,ENT_QUOTES,'UTF-8');
htmlspecialchars($ string,ENT_QUOTES,'UTF-8');
utf8_encode



但没有雪茄。页面设置为头文件中的UTF-8



MySQL数据库正在使用UTF-8太。如何让重音字符在UTF-8中正常显示?

解决方案

检查您的 @@ character_set_results 。默认情况下,MySQL使用 latin1 而不是 utf8 。尝试 SET NAMES utf8 mysqli :: set_charset



更新:这里是如何检查使用的字符集:

 code> mysql> SHOW VARIABLES LIKE'%char%'; 
+ -------------------------- + ------------------ ---------- +
| Variable_name |价值|
+ -------------------------- + ------------------ ---------- +
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem |二进制|
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | / usr / share / mysql / charsets / |
+ -------------------------- + ------------------ ---------- +

阅读更多关于 dev.mysql.com


I'm working on a French language site built in CakePHP. I have tried multiple functions to try and convert the text into UTF-8 and display properly, but have had no success so far - any accented letters are displaying as a black diamond with a question mark. They do display correctly when I change the char set in the browser to ISO-8859-1, but I'd like to make the while site UTF-8 compliant. I have used:

html_entity_decode($string, ENT_QUOTES, 'UTF-8'); htmlspecialchars($string, ENT_QUOTES, 'UTF-8'); utf8_encode

but no cigar. The page is set to UTF-8 in the header

And the MySQL database is using UTF-8 too. How can I get the accented characters to display properly in UTF-8?

解决方案

Check your @@character_set_results. By default, MySQL uses latin1, not utf8. Try SET NAMES utf8 or mysqli::set_charset.

Update: here is how you might check the character sets in use:

mysql> SHOW VARIABLES LIKE '%char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       | 
| character_set_connection | utf8                       | 
| character_set_database   | utf8                       | 
| character_set_filesystem | binary                     | 
| character_set_results    | utf8                       | 
| character_set_server     | utf8                       | 
| character_set_system     | utf8                       | 
| character_sets_dir       | /usr/share/mysql/charsets/ | 
+--------------------------+----------------------------+

Read more on dev.mysql.com.

这篇关于在UTF-8中显示法语重音字符的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆