如何将匈牙利MySQL条目转换为UTF8

发布于 2025-01-22 20:14:52 字数 328 浏览 4 评论 0 原文

我原则上了解了如何将现有数据库从拉丁语转换为UTF8。我已经能够使用拥有的数据库成功地做到这一点。

现有数据在匈牙利语中。以前,数据库字段设置为Latin1_german1_ci。结果,单词以这种方式存储在数据库中:

mâria

,但在前端中正确显示为:

mária,

如果我现在将所有内容都转换为UTF-8,则可以按照所有新数据进行工作。但是现有数据未在数据库中转换,并且完全显示在数据库中的数据库中:

Mâria

对我来说很有意义,因为它是UTF8。但这当然不是我想要的。但是,如何将数据库中的所有现有数据首先转换为“Mária”?

I have understood in principle how to convert an existing database from latin to utf8. I have already been able to do this successfully with the database I have.

The existing data is in Hungarian. The database fields were previously set to latin1_german1_ci. As a result, words were stored in the database in this way:

Mária

but in the frontend correctly shown as:

Mária

If I now convert everything to utf-8, it works as it should for all new data. But the existing data was not converted in the database and is displayed in the frontend exactly as it is in the database:

Mária

Which makes sense to me because it is utf8. But it is not what I want of course. But how do I get all the existing data in the database to be converted to e.g. "Mária" in first place?

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

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

发布评论

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

评论(1

梦回梦里 2025-01-29 20:14:52

这是一个“ mojibake”问题( 代替Á)参见

至于“转换”,首先决定您拥有的情况,然后应用给定的 alter(s) http://mysql.rjweb.org/mmysql.rjweb/mmysql.org/doc.php/doc.php/charcollcollcoll uchcoll

uchcoll_fixes_for_various_various_cases正确的方法。但是,在将其应用于生产之前进行测试。做“错误”的改变会造成一团糟。

请提供显示创建表的样本选择六角(Col),col ... ,以及用于提供Mojibake的查询。 显示诸如'char%'的变量

;但是您不妨去使用UTF8MB4。

That's a "Mojibake" problem (á in place of á) See Trouble with UTF-8 characters; what I see is not what I stored

As for "converting", first decide which case you have, then apply the given ALTER(s): http://mysql.rjweb.org/doc.php/charcoll#fixes_for_various_cases

Tentatively the 2-step ALTER may be the correct approach. However, test before applying it to production. Doing the 'wrong' Alter will leave quite a mess.

Please provide SHOW CREATE TABLE and a sample of SELECT HEX(col), col..., plus the query that was used to give the Mojibake. And SHOW VARIABLES LIKE 'char%';`

Note: For Western European languages, either utf8 or utf8mb4 would be sufficient. But you may as well go for utf8mb4.

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