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?
我试图在FusionChart图中的标签中输出sigma字符(σ)。如何在PHP字符串中指定该字符?我已经尝试了htmlentityσ,但图表没有正确解释。有没有办法使用某种字符代码在PHP中指定字符?
7 个解决方案
#1
You need to make sure you're sending the correct headers when outputting.
您需要确保在输出时发送正确的标题。
<?php
header('Content-Type: text/html; charset=utf-8');
$char = utf8_encode(html_entity_decode('σ'));
echo $char;
This will output the character.
这将输出字符。
Edit:
If passing the character into the graph doesn't work, then the software doesn't support UTF-8.
如果将字符传递到图形中不起作用,则软件不支持UTF-8。
#2
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 string
sigma(σ)可以通过字节顺序xCF x83(代码点U + 03C3)以UTF-8编码表示,因此您可以尝试构建PHP字符串
$sigma = "\xCF\x83";
But 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:
但由于我不知道FusionChart,我不能说它是否能够处理UTF-8编码的字符串或一般的多字节字符串。根据他们的产品描述,他们支持unicode(但需要UTF-8 BOM),因此您可以在PHP中构建XML响应:
$response = "\xEF\xBB\xEF<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<root>
<element attribute=\"\xCF\x83\">\xCF\x83</element>
</root>";
header('Content-Type: text/xml; charset=utf-8');
echo $response;
There is also a sigma (σ) character in ISO-8859-7 and Windows-1253 (xF3
) - but I doubt that this will help you.
ISO-8859-7和Windows-1253(xF3)中还有一个sigma(σ)字符 - 但我怀疑这对你有帮助。
Third option would be to specify some kind of mathematical symbol font that maps the sigma (σ) to some other character.
第三种选择是指定某种数学符号字体,将西格玛(σ)映射到其他字符。
#3
"\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.
“\ x1F”适用于常规ASCII字符,但我认为sigma是一个unicode字符,所以你将不得不使用像utf8_encode这样的东西。 PHP的Unicode支持很差。
#4
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.
对于FusionCharts,要在图表中显示小sigma,请使用%CF%83。将此百分比编码形式放在php字符串中。我试过这个。有用。另请查看有关使用特殊字符的文档页面:http://www.fusioncharts.com/docs/Contents/SpChar_Euro.html http://www.fusioncharts.com/docs/Contents/SpChar_Pound.html等。
#5
Save your .php file as utf-8 encode with bom enabled,and you can use directly a sigma character (σ).
将.php文件保存为启用了bom的utf-8编码,您可以直接使用sigma字符(σ)。
$sXML = "<chart><set value='20' label='σ' /></chart>";
echo renderChartHTML("../FusionCharts/Column2D.swf", "", "$sXML", "myFirst", 600, 300, false);
#6
What about:
html_entity_decode('σ');
PHP Manual for html_entity_decode
PHP手册html_entity_decode
#7
I could use chr(229) as well, where 229 is the ASCII code I'm looking for
我也可以使用chr(229),其中229是我正在寻找的ASCII码
#1
You need to make sure you're sending the correct headers when outputting.
您需要确保在输出时发送正确的标题。
<?php
header('Content-Type: text/html; charset=utf-8');
$char = utf8_encode(html_entity_decode('σ'));
echo $char;
This will output the character.
这将输出字符。
Edit:
If passing the character into the graph doesn't work, then the software doesn't support UTF-8.
如果将字符传递到图形中不起作用,则软件不支持UTF-8。
#2
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 string
sigma(σ)可以通过字节顺序xCF x83(代码点U + 03C3)以UTF-8编码表示,因此您可以尝试构建PHP字符串
$sigma = "\xCF\x83";
But 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:
但由于我不知道FusionChart,我不能说它是否能够处理UTF-8编码的字符串或一般的多字节字符串。根据他们的产品描述,他们支持unicode(但需要UTF-8 BOM),因此您可以在PHP中构建XML响应:
$response = "\xEF\xBB\xEF<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<root>
<element attribute=\"\xCF\x83\">\xCF\x83</element>
</root>";
header('Content-Type: text/xml; charset=utf-8');
echo $response;
There is also a sigma (σ) character in ISO-8859-7 and Windows-1253 (xF3
) - but I doubt that this will help you.
ISO-8859-7和Windows-1253(xF3)中还有一个sigma(σ)字符 - 但我怀疑这对你有帮助。
Third option would be to specify some kind of mathematical symbol font that maps the sigma (σ) to some other character.
第三种选择是指定某种数学符号字体,将西格玛(σ)映射到其他字符。
#3
"\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.
“\ x1F”适用于常规ASCII字符,但我认为sigma是一个unicode字符,所以你将不得不使用像utf8_encode这样的东西。 PHP的Unicode支持很差。
#4
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.
对于FusionCharts,要在图表中显示小sigma,请使用%CF%83。将此百分比编码形式放在php字符串中。我试过这个。有用。另请查看有关使用特殊字符的文档页面:http://www.fusioncharts.com/docs/Contents/SpChar_Euro.html http://www.fusioncharts.com/docs/Contents/SpChar_Pound.html等。
#5
Save your .php file as utf-8 encode with bom enabled,and you can use directly a sigma character (σ).
将.php文件保存为启用了bom的utf-8编码,您可以直接使用sigma字符(σ)。
$sXML = "<chart><set value='20' label='σ' /></chart>";
echo renderChartHTML("../FusionCharts/Column2D.swf", "", "$sXML", "myFirst", 600, 300, false);
#6
What about:
html_entity_decode('σ');
PHP Manual for html_entity_decode
PHP手册html_entity_decode
#7
I could use chr(229) as well, where 229 is the ASCII code I'm looking for
我也可以使用chr(229),其中229是我正在寻找的ASCII码