解码HTML特殊字符 [英] Decoding HTML Special Character

查看:81
本文介绍了解码HTML特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在PHP的帮助下将一些数据导出到CSV.该代码可以正常工作,但是我要导出的某些关键字位于我使用

I want to export some of my data into CSV with the help of PHP. The code is working correctly but some of the keywords that I want to export was in some other unicode which I had saved in database using

urlencode('אריה דרעי');

这将Unicode以这种格式保存在数据库中:

This saved the unicode in this format in database:

%26%231488%3B%26%231512%3B%26%231497%3B%26%231492%3B+%26%231491%3B%26%231512%3B%26%231506%3B%26%231497%3B

这里的主要问题是,当我将其显示在HTML页面中时,它显示得很好,但是当我尝试将其导出为CSV时,它显示了相同的文本.

The main problem here is when I display it in an HTML page it displays fine but when I try to export it in CSV it shows the same texts.

我尝试使用以下功能

url_decode('%26%231488%3B%26%231512%3B%26%231497%3B%26%231492%3B+%26%231491%3B%26%231512%3B%26%231506%3B%26%231497%3B');

但是它再次产生特殊字符为

But it again genereated special characters as

אריה דרעי

然后我尝试使用它进一步解码

Then I tried it to further decode using

 htmlspecialchars_decode();

但是它仍然在CSV文件中显示אריהדרעי.

But still it shows אריה דרעי in the CSV files.

我希望我有道理.

推荐答案

尝试使用htmlspecialchars()代替url_encode()

Try using htmlspecialchars() instead of url_encode()

http://www.php.net/manual/en/function.htmlspecialchars.php http://www.php.net/manual/zh/function.htmlspecialchars-decode.php

这篇关于解码HTML特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆