如何防止非ascii字符保存在Drupal数据库中?

发布于 2024-09-07 07:14:56 字数 417 浏览 5 评论 0原文

我注意到在 Drupal 中,一些用户在节点正文中输入内容后,引号和撇号等字符会保存为: ” “

这是由于用户输入了奇怪的字符或其他东西......

  1. 这是否意味着Drupal数据库 没有配置utf8?
  2. 如何才能纠正这个问题? 实际上保存为'?

更新 事实证明,就我而言,解码的字符是我下载 Drupal mysql 数据库转储的结果,该转储保存为 ascii 并将其加载到 Mysql 中以重新填充数据库。这种情况发生了两次,一次是在我迁移托管时,第二次是当我搞乱了数据库并且必须手动恢复时。

解决方案是您正在使用 Drupal 备份和迁移模块,并且您下载了备份文件,并且必须手动恢复,方法是将记事本或其他文件中的文件从 ascii 转换为 utf8。我测试了这个并且它有效。

I've noticed that in Drupal after some users enter content into the body of a node, characters like quotes and apostrophes get saved as:
’
“

This is due the user entering odd characters or something...

  1. Does this mean the Drupal database
    hasn't been configured for utf8?
  2. How can this be corrected so ’ is
    actually saved as just '?

UPDATE
Turns out, in my case, the decoded characters were a results of my downloading the Drupal mysql database dump which gets saved as ascii and loading that into Mysql to repopulate the database. This happened twice, once when I migrated hosting and the second time when I messed up the DB and had to restore is manually.

The solution is you are using the Drupal Backup and Migrate module and you download the backup file and have to restore manually is to convert the file in notepad or whatever from ascii into utf8. I tested this and it works.

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

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

发布评论

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

评论(2

﹎☆浅夏丿初晴 2024-09-14 07:14:56

’ ”' “ 的 UTF-8 编码,被误解为 windows-1252(不是 latin-1)。

这是否意味着Drupal数据库
尚未配置 utf8?

这是一种可能性。其他是:

  • 将数据放入数据库的程序损坏。
  • 从数据库检索数据的程序已损坏。

’ “ is the UTF-8 encoding of ’ “ misinterpreted as windows-1252 (not latin-1).

Does this mean the Drupal database
hasn't been configured for utf8?

That's one possibility. Others are:

  • The program that puts data in the database is broken.
  • The program that retrieves data from the database is broken.
紧拥背影 2024-09-14 07:14:56
  1. 这是否意味着 Drupal 数据库尚未配置为 utf8?

我想说最有可能的情况是数据库表设置为latin1。看看吧。或者,也可能是数据库连接不是 UTF-8 编码(发送 SET NAMES utf8; 查询有时会有所帮助。)

  1. Does this mean the Drupal database hasn't been configured for utf8?

I'd say it's the most likely possibility that the database table(s) are set to latin1. Take a look. Alternatively, it could also be that the database connection is not UTF-8 encoded (sending a SET NAMES utf8; query sometimes helps.)

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