MySQL 中的阿拉伯语脚本错误
我将数据插入到包含阿拉伯文字的 MySQL 数据库中。虽然输出正确显示阿拉伯语,但 MySQL 中的数据看起来像垃圾。像这样的事情:
'صَومُ ثَلاثَةِ أيّامٍ مِن كُلِّ شَهرٍ ـ أربَعاءُ بَينَ خَ
我应该担心这个吗?如果是,我如何让它在 MySQL 中以正确的阿拉伯文字显示?
I inserted data in a MySQL database which includes Arabic script. While the output displays Arabic correctly, the data in MySQL looks like garbage. Something like this:
'صَومُ ثَلاثَةِ أيّامٍ مِن كُلِّ شَهرٍ ـ أربَعاءُ بَينَ خَ
Should I be worried about this? If yes, how do I make it appear in proper Arabic script in MySQL?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这些是 HTML 实体。
如果这段文字
:您的阿拉伯人输入在某个时候被转换为这些实体。
要查看像上面这样的实际阿拉伯字符,请将它们插入到文本文件中,将其命名为
something.htm
并在浏览器中打开它。您还可以将其转换为 UTF-8 编码的 mySQL 表中的“正确”本机字符,但要获得任何指示,您必须告诉我们您正在使用哪些语言/平台。
Those are HTML entities.
If this text
is what is supposed to be in your database, everything's most likely fine: Your arabic input gets converted into those entities at some point along the way.
To view the actual arabic characters like above, insert them into a text file, name it
something.htm
and open it in your browser.You could also convert it into "proper" native characters in a UTF-8 encoded mySQL table, but for you to get any pointers how to do that you would have to tell us what languages/platforms you are working with.
正如 @Pekka 所说,这些是 HTML 实体。
然而,我不禁认为使用 UTF-8(对于数据库连接和 HTML 编码)从长远来看可能会为您减轻一些痛苦。同样,如果可能的话(即:如果这是一个“新”系统而不是现有的代码库)我建议将原始数据存储在数据库中(使用 mysql_real_escape_string 来防止 SQL 注入等)并在输出点。
一般来说,这将使搜索数据等变得更容易。
As @Pekka says, those are HTML entities.
However, I can't help but think using UTF-8 (for both the database connection and HTML encoding) might save you some pain in the long run. Likewise, if at all possible (i.e.: if this is a "new" system rather than an existing codebase) I'd recommend storing the data raw in the database (using mysql_real_escape_string to prevent SQL injection, etc.) and HTML encoding at the point of output.
In general, this will make it easier to search the data, etc.