FusionCharts allows you to display multi-lingual (UTF-8) characters on charts. The UTF-8 characters that are to be displayed must be encoded in the chart’s XML file. A FusionCharts object is essentially a Flash component and Flash offers no restriction on use of UTF-8 characters. However, it is essential that a byte-order mark be present in the UTF-8 encoding. So, to display UTF-8 characters in your chart, you need to stamp the UTF-8 encoded XML file with a byte-order mark.
As of now FusionCharts supports only left-to-right languages, as It doesn't have native support for right-to-left languages like Hebrew and Arabic. So, if you want to display Hebrew characters on charts, you'll have to programmatically change the text sequence before providing data to the chart.
Please do not specify the encoding of your XML file in the XML header region as this does not add the Byte Order Mark.
<?xml version="1.0" encoding="UTF-8"?>
UTF-8 may be the default encoding for XML files, but the encoding needs to be specified when saving the file. Also, you have to make sure that the application, which saves the file applies the BOM mark.
If the XML file is not encoded in UTF-8 format while saving, the characters will be displayed as gibberish.
Standard | Gibberish |
---|---|
![]() |
![]() |
The Adobe Flex platform automatically handles data sources with Unicode characters. However, if an external XML file is used as datasource, it must be encoded with a byte-order mark (BOM). The UTF-8 representation of BOM is the byte sequence EF BB BF (Hex-Decimal Notation), which appears as the ISO-8850-1 characters  in most text-editors. Depending on the method of XML generation that you have used, you can follow any one of the various method of BOM stamping that has been discussed below.
This method is applicable when inline static Flex data sources such as String, Array, XML, or Model are used. The Unicode characters can be directly typed using a multi-lingual interface. They can also be specified with the help of \u escape sequence and the appropriate UTF Hex-Code.
// Chart declared using Array data type
private var chartParams:ArrayCollection=new ArrayCollection([
{caption: "藤原とふショプ \u00A9"},
.....
]);
// A Japanese caption, followed by copyright sign
You can manually insert a BOM mark for those XML files, which remain static once they have been generated. This method may be implemented if data is retrieved from a file with the help of the FCDataURL attribute. All you have to do is ensure the file containing the XML data also contains a BOM mark. In case the BOM mark is not present, specify it manually by following these steps::
For XML files that are generated by other applications and are outside the scope of manual manipulation, you need to control the process of XML generation – in order to incorporate the BOM mark. This method may be implemented if data is retrieved from a file using the FCDataURL attribute. Following solutions have been provided to help you incorporate BOM mark in XML files generated using various server-side scripts.
Insert the following code block at the beginning of page generation before outputting any data.
Response.AddHeader "Content-Type", "text/xml;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8"
Response.BinaryWrite(chrb(239))
Response.BinaryWrite(chrb(187))
Response.BinaryWrite(chrb(191))
Insert the following code block at the beginning of the page generation before you output the XML.
Response.ContentType = "text/xml; characterset=utf-8";
Response.BinaryWrite(new byte[] { 0xEF, 0xBB, 0xBF });
Insert the following code block at the beginning of page generation. The output of the XML should follow this.
Response.ContentType = "text/xml"
Dim UTFHeader() As Byte = {&HEF, &HBB, &HBF}
Response.BinaryWrite(UTFHeader)
Insert the following code block at the beginning of page generation before outputting XML data.
header('Content-type: text/xml');
echo pack("C3",0xef,0xbb,0xbf);
Insert the following code block at the beginning of page generation. Output the XML after this.
context = getPageContext();
response = context.getResponse().getResponse();
out = response.getOutputStream();
out.write(239);
out.write(187);
out.write(191);
For outputting data, you must convert the string to UTF-8 format. Using the getBytes("UTF-8") method for strings.
Place the following code block at the beginning of page generation. Output any data after this block.
response.setContentType("text/xml; charset=UTF-8");
OutputStream outs = response.getOutputStream();
outs.write(new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF});
outs.flush();
While using data sources that are dynamically generated by other applications, you do not need to specify a BOM mark. This is because; the data passed, will be converted to a Flex data source before being transferred to the FusionCharts object. In this process the data is automatically formatted and no explicit declaration is necessary.