使用 PHP 和 MySQL 进行希伯来语编码
我目前正在编写一个 php5 Web 应用程序。它假设从数据库中提取数据并将其显示在 HTML 页面中。为了显示希伯来语字符,HTML 中的字符集编码为:charset=windows-1255
该应用程序配置为与 MySQL 一起使用。 我对希伯来语编码有疑问,这实际上是某种悖论......
1. 当我将数据库表中的排序规则配置为 UTF_bin
和字符集 UTF-8
时:
从数据库中提取的希伯来语字符显示正常,但 HTML 希伯来语字符显示不正常。
2. 当我将数据库表中的排序规则配置为 UTF_bin
和字符集 windows-1255
时:
从数据库中提取的希伯来语字符显示为随机字符,HTML 希伯来语是可以的。
有谁知道如何解决它吗?
谢谢!
I'm currently writing a php5 web application. It suppose to extract data from the DB and show it in an HTML page. In order to show Hebrew characters, the charset encoding in the HTML is:charset=windows-1255
The application is configured to work with MySQL.
I have problems with the Hebrew encoding, it's actually some kind of paradox...
1. When I configure the collation in the DB table to be UTF_bin
and the charset UTF-8
:
The Hebrew characters that extracted from the db are shown fine, the HTML Hebrew not.
2. When I configure the collation in the DB table to be UTF_bin
and the charset windows-1255
:
The Hebrew characters that extracted from the db are show are show as random characters, the HTML Hebrew is ok.
Does anyone has an idea how to solve it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有简单的编码示例/示例吗?
我假设您已经..
1) 也在 HTTP Content-Type 标头的末尾附加了字符集?
header('内容类型:text/xhtml; charset=windows-1255');
以及标签?
2)使用多字节字符串函数http://php.net/manual/en/book。 mbstring.php 或重载所有字符串函数 http://www.php.net/manual/en/mbstring.overload.php,和/或 hebrev() 或 hebrevc()(如果需要)
3) 并且您正在使用 setlocale () 对于其他本地化 http://php.net/manual/en/function.setlocale。 php
如果您将 UTF 从数据库中提取出来,您可能需要使用 iconv() 或类似的方法将其转换为另一种编码?
http://www.php.net/manual/en/function.iconv.php
Do you have a simple coding sample/example?
I assume you've..
1) appended the charset on the end of the HTTP Content-Type header too?
header('Content-type: text/xhtml; charset=windows-1255');
as well as the tag?
2) using multi byte string functions http://php.net/manual/en/book.mbstring.php or are overloading all string functions http://www.php.net/manual/en/mbstring.overload.php, and/or hebrev() or hebrevc() where required
3) and you're using setlocale() for other localisations http://php.net/manual/en/function.setlocale.php
If you're pulling UTF out of the DB, you may need to use iconv() or similar to translate it to another encoding?
http://www.php.net/manual/en/function.iconv.php