Html实体像& euro;在CSV转换中不会转换为其符号 [英] Html entities like € is not converted to its symbol in CSV conversion

查看:151
本文介绍了Html实体像& euro;在CSV转换中不会转换为其符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了来自 http://code.google.com/p的CSV解析器/ parsecsv-for-php / ,以便将我的报表以PHP格式导出为CSV。我在浏览器以及Excel(导出后)中显示& euro; XXXX.XX 中的销售总值,显示为欧元符号。

I have used CSV parser from http://code.google.com/p/parsecsv-for-php/, to export my reports to CSV in PHP. I have displayed Sales Total value in €XXXX.XX, in browser as well as in Excel(After exporting), displayed with the Euro symbol.

但是在CSV中,而不是欧元符号,它只显示代码& euro;

But in CSV, instead of Euro symbol, its showing the code € only.

如何导出& euro; ,将其对应的符号导出为CSV。

How can I export that € to it's corresponding symbol to CSV.

提前感谢。
快乐编码:)

Thanks in advance. Happy coding :)

推荐答案

您需要使用 html_entity_decode c $ c>在字符串之前写入到文件,这将找到所有的html实体,并替换为他们的实际符号。

You would need to use html_entity_decode() on the strings before writing them to file, which will find all html entities and replace them with their actual symbol.

html_special_chars() html_special_chars_decode()& gt; & lt; 的几个html实体上,而 htmlentities() html_entity_decode()适用于所有这些。

html_special_chars() and html_special_chars_decode() only works on a few html entities, like > and <, while htmlentities() and html_entity_decode() works on all of them.

你可以只对 str_replace() preg_replace() >

然后尝试:

str_replace('& euro;','€',$ valuebeingexported);

这篇关于Html实体像& euro;在CSV转换中不会转换为其符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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