Using Multi-lingual text in FusionCharts

http://www.fusioncharts.com/Docs/Contents/SpChar.html

 

 

Using Multi-lingual text in FusionCharts

 

FusionCharts allows you to use multi-lingual (UTF-8) characters on the charts. Shown below is an example where we've used Arabic names on the chart:

You can use multi-lingual characters in all the charts in FusionCharts v3 suite.

FusionCharts supports only left-to-right languages as of now. It doesn't have native support for right-to-left languages like Hebrew. So, if you want to use Hebrew with FusionCharts, you'll have to programatically change the text sequence and then provide the data to FusionCharts.

 
How to use multi-lingual characters?

To use multi-lingual characters on the chart, you necessarily need to use UTF-8 encoded XML. More importantly, the XML file/stream does require a BOM stamp to be present as the very first 3 Bytes of the file. Hence, one must remember the two basic thumb rules :

  1. for dataURL method - the XML file/stream should be having the BOM stamp and
  2. for dataXML method - the HTML/application file containing the XML as well as the chart SWF should have the BOM stamp.
 
What is BOM - Byte Order Mark. It is 'EF BB EF' - these 3 bytes in case of UTF-8 encoded files, the BOM being placed at the very begining of the file. It is an indicator that the file is containing UTF-8 encoded strings.
 
WARNING : Do not rely on specifying the encoding setting i.e. <?xml version="1.0" encoding="UTF-8"?> in the XML header region. This does not add the Byte Order Mark (BOM) to the XML file.
 
Please note that without the BOM stamp the chart would produce gibberish characters. Please compare the images below:
 
Standard (with BOM) Gibberish (without BOM)
 
 
1. In static XML
 
For the XML files which are generated one-time and remains static, you can manually insert a BOM mark. This method is applicable when data is retrieved from file using the dataURL method. All you have to do is make sure the file containing the XML data contains a BOM mark or specify one if it is absent. In order to specify a BOM mark, follow these steps:
  1. Open the file in question in a text-editor that supports UTF-8 encoding with BOM stamp (Example – Windows Notepad).
  2. Open the save menu and specify file name, file type, encoding and BOM mark (if the option is available).
  3. Save the file.
 
The image below shows how this can be done in Windows Notepad.
 
The image below shows how this can be done in Dreamweaver for mac.
 
2. In dynamically generated XML using server-side script
 

Ideally, in most of the cases you would NOT use a physical data file. Instead you'll have your own server side scripts virtually relay the XML data document to the chart. Thus this would come outside the scope of manual maintenance. Rather, you must write some code in the server side script to add the BOM stamp. The method is best practised when UTF-8 encoded strings are retrieved from databases and smilar locations. The implementation can be done using either of the two methods:

  1. Manually add BOM to the XML realyer script file - just like adding BOM stamp to the static XML files you can also add the BOM stamp to the server side file which would be realying the dynamically generaeted XML. This needs to be done when the script file is created for the first time before you start coding in it.

  2. Write BOM using script - In most cases the XML relayer script file might be created with ANSI encoded format. In this case, one needs to add the BOM using script at the very begining of the output stream. Moreover, when a server side script creates an XML file, it should add the BOM stamp as the very first 3 bytes of the file.

 

We list below techniques to implement BOM stamp using major server side technologies.
 
Using ASP.NET C#
 

Response.ContentType = "text/xml; characterset=utf-8" ;
Response.BinaryWrite( new byte[] { 0xEF, 0xBB, 0xBF } );

// Now write your XML data to output stream

 
Using ASP.NET VB
 

Response.ContentType = "text/xml"
Dim UTFHeader() As Byte = {&HEF, &HBB, &HBF}
Response.BinaryWrite(UTFHeader)

' Now write your XML data to output stream

 
Using PHP
 

header ( 'Content-type: text/xml' );
echo pack
( "C3" , 0xef, 0xbb, 0xbf );

// Now write your XML data to output stream

 
Using ASP
 

Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8"

Response.BinaryWrite( chrb(239) )
Response.BinaryWrite( chrb(187) )
Response.BinaryWrite( chrb(191) )

' Now write your XML data to output stream

 
Using JSP
 

response.setContentType( "text/xml; charset=UTF-8" );
OutputStream outs = response.getOutputStream();
outs
.write( new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF} );
outs.flush();

// Now write your XML data to output stream

 
Using ColdFusion
 

context = getPageContext();
response
= context.getResponse().getResponse();
out = response.getOutputStream();

out
.write(239);
out.write(187);
out.write(191);

// Now write your XML data to output stream

 
Using ROR
 

utf8_arr = [0xEF,0xBB,0xBF]
utf8_str = utf8_arr.pack("c3")

# Now write your XML data to output stream

 
3. While using dataXML method
 
In many cases you might need to put the XML in the HTML/application file itself. We call this as dataXML method. Just like adding BOM stamp to a static XML files, in this case too you would need to save the file containing the chart SWF and XML with BOM stamp. This needs to be done when the script/HTML file is created for the first time before you start coding in it.
 

Using Multi-lingual text in FusionCharts 
 
 
FusionCharts allows you to use multi-lingual (UTF-8) characters on the charts. Shown below is an example where we've used Arabic names on the chart:
 
 
You can use multi-lingual characters in all the charts in FusionCharts v3 suite.

FusionCharts supports only left-to-right languages as of now. It doesn't have native support for right-to-left languages like Hebrew. So, if you want to use Hebrew with FusionCharts, you'll have to programatically change the text sequence and then provide the data to FusionCharts.
 
 
How to use multi-lingual characters? 
To use multi-lingual characters on the chart, you necessarily need to use UTF-8 encoded XML. More importantly, the XML file/stream does require a BOM stamp to be present as the very first 3 Bytes of the file. Hence, one must remember the two basic thumb rules :

1.for dataURL method - the XML file/stream should be having the BOM stamp and
2.for dataXML method - the HTML/application file containing the XML as well as the chart SWF should have the BOM stamp.
 
 
What is BOM - Byte Order Mark. It is 'EF BB EF' - these 3 bytes in case of UTF-8 encoded files, the BOM being placed at the very begining of the file. It is an indicator that the file is containing UTF-8 encoded strings. 
 
WARNING : Do not rely on specifying the encoding setting i.e. <?xml version="1.0" encoding="UTF-8"?> in the XML header region. This does not add the Byte Order Mark (BOM) to the XML file.
 
Please note that without the BOM stamp the chart would produce gibberish characters. Please compare the images below: 
 
Standard (with BOM)  Gibberish (without BOM) 
 
 
 
How to add BOM ?
 
1. In static XML 
 
For the XML files which are generated one-time and remains static, you can manually insert a BOM mark. This method is applicable when data is retrieved from file using the dataURL method. All you have to do is make sure the file containing the XML data contains a BOM mark or specify one if it is absent. In order to specify a BOM mark, follow these steps:
1.Open the file in question in a text-editor that supports UTF-8 encoding with BOM stamp (Example – Windows Notepad).
2.Open the save menu and specify file name, file type, encoding and BOM mark (if the option is available).
3.Save the file.
 
 
The image below shows how this can be done in Windows Notepad. 
 
 
The image below shows how this can be done in Dreamweaver for mac.
 
 
2. In dynamically generated XML using server-side script
 
Ideally, in most of the cases you would NOT use a physical data file. Instead you'll have your own server side scripts virtually relay the XML data document to the chart. Thus this would come outside the scope of manual maintenance. Rather, you must write some code in the server side script to add the BOM stamp. The method is best practised when UTF-8 encoded strings are retrieved from databases and smilar locations. The implementation can be done using either of the two methods:

1.Manually add BOM to the XML realyer script file - just like adding BOM stamp to the static XML files you can also add the BOM stamp to the server side file which would be realying the dynamically generaeted XML. This needs to be done when the script file is created for the first time before you start coding in it.


2.Write BOM using script - In most cases the XML relayer script file might be created with ANSI encoded format. In this case, one needs to add the BOM using script at the very begining of the output stream. Moreover, when a server side script creates an XML file, it should add the BOM stamp as the very first 3 bytes of the file.
 
 
We list below techniques to implement BOM stamp using major server side technologies. 
 
Using ASP.NET C# 
 
Response.ContentType = "text/xml; characterset=utf-8" ;
Response.BinaryWrite( new byte[] { 0xEF, 0xBB, 0xBF } );

// Now write your XML data to output stream
 
 
Using ASP.NET VB 
 
Response.ContentType = "text/xml"
Dim UTFHeader() As Byte = {&HEF, &HBB, &HBF}
Response.BinaryWrite(UTFHeader)

' Now write your XML data to output stream
 
 
Using PHP 
 
header ( 'Content-type: text/xml' );
echo pack ( "C3" , 0xef, 0xbb, 0xbf );

// Now write your XML data to output stream
 
 
Using ASP 
 
Response.ContentType = "text/html"
Response.AddHeader "Content-Type", "text/html;charset=UTF-8"
Response.CodePage = 65001
Response.CharSet = "UTF-8"

Response.BinaryWrite( chrb(239) )
Response.BinaryWrite( chrb(187) )
Response.BinaryWrite( chrb(191) )

' Now write your XML data to output stream
 
 
Using JSP 
 
response.setContentType( "text/xml; charset=UTF-8" );
OutputStream outs = response.getOutputStream();
outs.write( new byte[]{(byte)0xEF, (byte)0xBB, (byte)0xBF} );
outs.flush();

// Now write your XML data to output stream
 
 
Using ColdFusion 
 
context = getPageContext();
response = context.getResponse().getResponse();
out = response.getOutputStream();

out.write(239);
out.write(187);
out.write(191);

// Now write your XML data to output stream
 
 
Using ROR 
 
utf8_arr = [0xEF,0xBB,0xBF]
utf8_str = utf8_arr.pack("c3")

# Now write your XML data to output stream
 
 
3. While using dataXML method
 
In many cases you might need to put the XML in the HTML/application file itself. We call this as dataXML method. Just like adding BOM stamp to a static XML files, in this case too you would need to save the file containing the chart SWF and XML with BOM stamp. This needs to be done when the script/HTML file is created for the first time before you start coding in it.
 

Python网络爬虫与推荐算法新闻推荐平台:网络爬虫:通过Python实现新浪新闻的爬取,可爬取新闻页面上的标题、文本、图片、视频链接(保留排版) 推荐算法:权重衰减+标签推荐+区域推荐+热点推荐.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值