Symbian中的一些编码转换API
2010-08-31 00:13:00 来源:WEB开发网前言:在Symbian中的中文字都是用unicode编码来完成的 ,所以通过功能函数转换为uncode或者保存为unicode文件就可以解决中文显示的问题了。
以下是Symbian中提供的几个关于编码格式转换的API接口和粗略说明 ( 以功能逐渐强大为序 ):
1) Class EscapeUtils
Description
Provides an API to allow data to be escape encoded and decoded. Also provide an API for converting a UNICODE data (16-bit descriptor) into UTF8 data (8-bit descriptor) and vice-verse.
注:EscapeUtils工具类中也包含了将URL进行编码的简单接口(不好用)。
Location: EscapeUtils.h
Link against: inetprotutil.lib
2) class CnvUtfConverter
Description
Converts text between Unicode (UCS-2) and the two Unicode transformation formats UTF-7 and UTF-8. There are no functions to convert directly between UTF-7 and UTF-8.
Objects of this class do not need to be created because all the member functions are static. The four functions are passed text in the second argument and output the resulting text in the first argument. Sixteen-bit descriptors are used to hold text encoded in UCS-2 (i.e. normal 16 bit Unicode), and eight-bit descriptors are used to hold text encoded in either of the transformation formats.
The conversion functions return the number of characters which were not converted because the output descriptor was not long enough to hold all of the converted text. This allows users of this class to perform partial conversions on an input descriptor, handling the case when the input descriptor is truncated mid way through a multi-byte character. The caller does not have to guess how big to make the output descriptor for a given input descriptor- they can simply do the conversion in a loop using a small output descriptor. The ability to handle truncated descriptors is particularly useful if the caller is receiving information in chunks from an external source.
更多精彩
赞助商链接