Question

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?

Was it helpful?

Solution

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('&sigma;'));

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.

OTHER TIPS

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";

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:

$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.

Third option would be to specify some kind of mathematical symbol font that maps the sigma (σ) to some other character.

"\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.

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.

Save your .php file as utf-8 encode with bom enabled,and you can use directly a sigma character (σ).

    $sXML = "<chart><set value='20' label='σ' /></chart>";
echo renderChartHTML("../FusionCharts/Column2D.swf", "", "$sXML", "myFirst", 600, 300, false);

What about:

html_entity_decode('&sigma;');

PHP Manual for html_entity_decode

I could use chr(229) as well, where 229 is the ASCII code I'm looking for

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top