MySQL uft8_unicode_ci

发布于 2024-09-16 23:33:24 字数 605 浏览 1 评论 0原文

我想确保写了一些东西。

我的数据库表是 utf8_unicode_ci ,我的站点编码和标头是 utf-8 等等。

我做了一个测试,在我的留言簿中输入了以下内容:

á
ʵßăāÇϢϞﻨ☺ 

▓ ▓ẻ ▓ẻṎ

۞ ݤ

现在很棒,它像它应该的那样显示在网页上,并且我测试了其他语言等,但是在 phpmyadmin 中检查此内容时,它在 phpmyadmin 中的文本字段值区域中显示为:

á
ʵßăÄÇϢϞﻨ☺ 

▓ ▓ẻ ▓ẻṎ

۞ ݤ

可以有人告诉我为什么在 phpmyadmin 中显示这样吗?我的意思是它是这样存储的并且是正常的还是应该完全按照我输入的方式存储?这种情况也发生在所有外语上,例如中文等。基本上都是外语。

我检查以确保在 phpmyadmin 中显示:

MySQL 连接排序规则:utf8_unicode_ci 和 MySQL 字符集:UTF-8 Unicode (utf8)

也许是 phpmyadmin?如果是这样,我必须做什么才能让 phpmyadmin 正确显示 utf-8,要么 MySQL 没有正确存储它,尽管它在输出到网页时显示正常。

I want to make sure something is write.

My database tables are utf8_unicode_ci and my site encoding and header is utf-8 etc and so on.

I done a test and in my guestbook I entered this:

á
ʵßăāÇϢϞﻨ☺ 

▓ ▓ẻ ▓ẻṎ

۞ ݤ

Now great it displays on the webpage like it should and i tested other languages to etc, but on checking this in phpmyadmin it is showing in the text field value area in phpmyadmin as:

á
ʵßăÄÇϢϞﻨ☺ 

▓ ▓ẻ ▓ẻṎ

۞ ݤ

Can someone tell me why this is showing like this in phpmyadmin? I mean is it stored like that and it that normal or should it be stored exactly as I typed it? It is happening on all foreign language like chineese etc as well. Basically all foreign languages.

I checked to ensure and in phpmyadmin it says:

MySQL connection collation: utf8_unicode_ci
and
MySQL charset: UTF-8 Unicode (utf8)

Maybe it's phpmyadmin? if so what must I do to get phpmyadmin to display utf-8 correctly, either that or MySQL is not storing it correctly although it displays fine when outputting to webpage.

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

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

发布评论

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

评论(1

非要怀念 2024-09-23 23:33:24

不,它不是 PhpMyAdmin。它一直使用UTF-8。

PHP 应用程序本身的数据库连接可能不使用 UTF-8。尽管从一侧传输到另一侧的字节是相同的,但它们使用错误的字符集进行编码和解码,即平台默认字符集,根据 Mojibake 字符(UTF-8 对/三元组的第一个字符通常变为 àÂÄ 等)。

您需要让 PHP 使用 mysql_set_charset()表明您正在使用 UTF-8 数据:

mysql_set_charset("utf8");

请注意,这仅适用于 PHP >= 5.2.3 和 MySQL >= 5.0.7,否则您需要执行 SET NAMES 查询,另请参阅前面链接的 PHP 手册。另请注意,您需要截断并用新数据重新填充数据库,如果不使用某些 SQL 脚本将其转换回来,您将无法再在网页上重新显示它。

No, it is not PhpMyAdmin. It has always been using UTF-8 all the time.

The DB connection in your PHP application itself is likely not using UTF-8. Although the bytes which are transferred from one to the other side are the same, they are been encoded and decoded using the wrong charset, namely the platform default one which is most likely ISO-8859-1 as per the patterns of the Mojibake characters (first character of the UTF-8 pair/triplet becomes then often Ã, Â, Ä and like).

You need to let PHP inform MySQL using mysql_set_charset() that you're working with UTF-8 data:

mysql_set_charset("utf8");

Note that this only works in PHP >= 5.2.3 and MySQL >= 5.0.7, else you need to do a SET NAMES query instead, see also the aforelinked PHP manual. Also note that you need to truncate and refill the DB with new data, you can't redisplay it on the webpage anymore without converting it back using some SQL script.

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