无法找出我的 Ruby 1.9 字符串编码在哪里被搞乱了

发布于 2024-08-23 09:18:29 字数 349 浏览 5 评论 0原文

从数据库到应用程序的某个地方,这个:

sauté

正在变成这个:

sauté

我正在使用 Ramaze + Rack + MySQL。我设置了一个force_encoding插件,所以字符串的编码是UTF-8。如果我在数据库 shell 中查看记录,它看起来很好。表上的默认字符集是utf8,字段本身是“text”。我的数据库连接的编码是utf8。另外,在我的 Macbook 上,一切都运行良好。它在我的 Ubuntu 服务器上被破坏了。我希望有人能认识到这一点并告诉我这是 unicode 转换为 ASCII,然后又转换回来,或者类似的事情。

Somewhere along the line from the DB to the application, this:

sauté

is getting turned into this:

sauté

I'm using Ramaze + Rack + MySQL. I've got a force_encoding plugin set up, so the encoding on the string is UTF-8. If I view the record in the database shell, it's looks fine. The default charset on the table is utf8, and the field itself is "text". The encoding on my database connection is utf8. Also, on my Macbook, everything works great. It's on my Ubuntu server that it's getting mangled. I'm hoping that someone may recognize this and tell me that it's unicode getting turned to ASCII, then back, or something like that.

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

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

发布评论

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

评论(1

来日方长 2024-08-30 09:18:29

您的区域设置很可能有所不同。
在两者上运行 locale 命令,看看有什么区别。
我假设您在从 MySQL 返回结果时看到一个问题,根据 google 结果,这是 1.9 的常见问题: http://www.google.com/search?q=mysql+ruby+1.9+encoding

Most likely your locale differs.
Run the locale command on both and see what's the difference.
I assume you see an issue when you get results back from MySQL, which is a common issue with 1.9 according to google results: http://www.google.com/search?q=mysql+ruby+1.9+encoding.

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