西班牙语字符编码不正确

发布于 2024-10-18 06:11:00 字数 1283 浏览 2 评论 0原文

我正在菲律宾开展一个项目,那里很多人的名字中都有特殊的拉丁波浪号字符。

我设置了一个数据库,其中所有表均采用 latin1_swedish_ci 排序规则。

+--------------------------+--------------------------------+
| Variable_name            | Value                          |
+--------------------------+--------------------------------+
| character_set_client     | latin1                         |
| character_set_connection | latin1                         |
| character_set_database   | latin1                         |
| character_set_filesystem | binary                         |
| character_set_results    | latin1                         |
| character_set_server     | latin1                         |
| character_set_system     | utf8                           |
| character_sets_dir       | C:\xampp\mysql\share\charsets\ |
+--------------------------+--------------------------------+

我的网页标题声明 iso-8859-1 作为字符集。

例如,当我通过网络表单提交包含波浪号字符的员工姓名时,它在我的表格中显示为“Marie Cañon”,并且当我查看该员工的记录时,它在我的网页上显示相同。

如果我将网页编码更改为 utf-8,它会正确显示为“Marie Cañon”。所以,我假设我在 latin1 表中以某种方式编码 UTF-8。但我很困惑这可能发生在哪里。

据我所知,PDO 不处理编码。我的网页已声明为 iso-8859-1,因此我认为 PHP 不会导致该问题。我的character_set_connection在MySQL中是latin1。

这可能发生在哪里?

附加信息: Ubuntu 10.04.2 LTS MySQL 5.1.41-3ubuntu12.9-日志 PHP5:5.3.2 阿帕奇2:2.2.14

I'm working on a project in the Philippines where many people have special Latin tilde characters in their names.

I have a database set up with all tables in latin1 with latin1_swedish_ci collation.

+--------------------------+--------------------------------+
| Variable_name            | Value                          |
+--------------------------+--------------------------------+
| character_set_client     | latin1                         |
| character_set_connection | latin1                         |
| character_set_database   | latin1                         |
| character_set_filesystem | binary                         |
| character_set_results    | latin1                         |
| character_set_server     | latin1                         |
| character_set_system     | utf8                           |
| character_sets_dir       | C:\xampp\mysql\share\charsets\ |
+--------------------------+--------------------------------+

My webpage headers declare iso-8859-1 as the character set.

When I submit an employee name containing a tilde character through my web forms, for example, it appears in my table as 'Marie Cañon' and appears the same on my webpages when I look at the employee's record.

If I change the webpage encoding to utf-8, it displays correctly as 'Marie Cañon'. So, I'm assuming that somehow I'm encoding UTF-8 in my latin1 tables. But I'm confused where that could be occurring.

As far as I know, PDO doesn't deal with encoding. My webpages are declared iso-8859-1, so I'm figuring PHP isn't causing the problem. My character_set_connection is latin1 in MySQL.

Where could this be happening?

Additional Information:
Ubuntu 10.04.2 LTS
MySQL 5.1.41-3ubuntu12.9-log
PHP5: 5.3.2
Apache2: 2.2.14

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

拧巴小姐 2024-10-25 06:11:00

这对我有用:

$title = mb_convert_encoding($article['title'], "UTF-8", "iso-8859-1");

适合西班牙口音

This worked for me:

$title = mb_convert_encoding($article['title'], "UTF-8", "iso-8859-1");

for Spanish accents

半世晨晓 2024-10-25 06:11:00
  1. 将 MySQL 切换为 utf-8。
  2. 安装 mbstring PHP 扩展并进行配置。
  3. 制作 PHP 标头: header('Content-type: text/html; charset=UTF-8');
  4. HTMLheaders
  5. 检查此
  1. Switch your MySQL to utf-8.
  2. Install the mbstring PHP extension and configure it.
  3. Make your PHP headers: header('Content-type: text/html; charset=UTF-8'); and
  4. HTMLheaders <meta http-equiv="Content-type" value="text/html; charset=UTF-8" /> and
  5. check this cheat sheet.
相思碎 2024-10-25 06:11:00

我在从数据库中获取字符串时解决了这个问题,添加了以下内容:

$var = utf8_encode(strtoupper(mysql_result($query, $i, 0)));

I resolved it when picking up the string from the database adding this:

$var = utf8_encode(strtoupper(mysql_result($query, $i, 0)));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文