如何防止非ascii字符保存在Drupal数据库中?
我注意到在 Drupal 中,一些用户在节点正文中输入内容后,引号和撇号等字符会保存为: ” “
这是由于用户输入了奇怪的字符或其他东西......
- 这是否意味着Drupal数据库 没有配置utf8?
- 如何才能纠正这个问题? 实际上保存为'?
更新 事实证明,就我而言,解码的字符是我下载 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...
- Does this mean the Drupal database
hasn't been configured for utf8? - 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
’ ”
是' “
的 UTF-8 编码,被误解为 windows-1252(不是 latin-1)。这是一种可能性。其他是:
’ “
is the UTF-8 encoding of’ “
misinterpreted as windows-1252 (not latin-1).That's one possibility. Others are:
我想说最有可能的情况是数据库表设置为
latin1
。看看吧。或者,也可能是数据库连接不是 UTF-8 编码(发送SET NAMES 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 aSET NAMES utf8;
query sometimes helps.)