PHP中如何指定特殊字符
我正在尝试在 FusionChart 图中的标签中输出西格玛字符 (σ)。 如何在 PHP 字符串中指定该字符? 我尝试过 htmlentity σ
,但图表无法正确解释它。 有没有办法使用某种字符代码来指定 PHP 中的字符?
I am trying to output a sigma character (σ) in a label in a FusionChart graph. How can I specify that character in a PHP string? I have tried the htmlentity σ
, but it is not interpreted correctly by the graph. Is there any way to specify the character in PHP using some sort of character code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
您需要确保在输出时发送正确的标头。
这将输出字符。
编辑:
如果将字符传递到图形中不起作用,则该软件不支持 UTF-8。
You need to make sure you're sending the correct headers when outputting.
This will output the character.
Edit:
If passing the character into the graph doesn't work, then the software doesn't support UTF-8.
"\x1F"
适用于常规 ASCII 字符,但我认为 sigma 是 unicode 字符,因此您必须使用类似 utf8_encode。 PHP 对 Unicode 的支持很差。"\x1F"
will work for regular ASCII characters, but I think sigma is a unicode character, so you're going to have to use something like utf8_encode. PHP has poor Unicode support.西格玛 (σ) 可以通过字节序列
xCF x83
(代码点 U+03C3)以 UTF-8 编码表示,因此您可以尝试构建 PHP 字符串但正如我不'不知道FusionChart,我不能说它是否可以处理UTF-8编码的字符串或多字节字符串。根据他们的产品描述,他们确实支持unicode(但需要UTF-8 BOM< /strong>),这样您就可以在 PHP 中构建 XML 响应:ISO-8859-7 和 Windows-1253 中还有一个西格玛 (σ) 字符 (xF3
) - 但我怀疑这会对您有帮助。第三个选项是指定某种数学符号字体,将 sigma (σ) 映射到其他某个字符。The sigma (σ) can be represented in UTF-8 encoding by the byte sequende
xCF x83
(codepoint U+03C3), so you could try to build a PHP stringBut as I don't know FusionChart, I cannot say if it can handle UTF-8 encoded strings or multi-byte strings in general.According to their product description, they do support unicode (but require a UTF-8 BOM), so you can build the XML response in PHP:There is also a sigma (σ) character in ISO-8859-7 and Windows-1253 (xF3
) - but I doubt that this will help you.Third option would be to specify some kind of mathematical symbol font that maps the sigma (σ) to some other character.我也可以使用 chr(229),其中 229 是我正在寻找的 ASCII 代码
I could use chr(229) as well, where 229 is the ASCII code I'm looking for
对于 FusionCharts,要在图表中显示小西格玛,请使用 %CF%83。 将此百分比编码形式放入 php 字符串中。
我已经尝试过了。 有用。 另请在此处查看有关使用特殊字符的文档页面: http://www.fusioncharts.com /docs/Contents/SpChar_Euro.html
http://www.fusioncharts.com/docs/Contents/SpChar_Pound.html
ETC。
For FusionCharts, to show small sigma in the chart, please use %CF%83. Put this percentage encoded form in a php string.
I have tried this. It works. Also check the documentation pages on using special characters here: http://www.fusioncharts.com/docs/Contents/SpChar_Euro.html
http://www.fusioncharts.com/docs/Contents/SpChar_Pound.html
etc.
将您的 .php 文件保存为启用 bom 的 utf-8 编码,您可以直接使用西格玛字符 (σ)。
Save your .php file as utf-8 encode with bom enabled,and you can use directly a sigma character (σ).
怎么样:
html_entity_decode 的 PHP 手册
What about:
PHP Manual for html_entity_decode