utfconverter.h

来自「这个是symbian下的一个蛮庞大的3D游戏源代码!对于学习3D开发的人有很大的」· C头文件 代码 · 共 86 行

H
86
字号
#ifndef _LANG_UTFCONVERTER_H
#define _LANG_UTFCONVERTER_H


#include <lang/Converter.h>


namespace lang
{


/**
 * Unicode UTF-data encoding/decoding helper class.
 * Supported encoding schemes are ASCII-7, UTF-8, UTF-16BE,
 * UTF-16LE, UTF-32BE, UTF-32LE.
 *
 * 
 * @ingroup lang
 */
class UTFConverter :
	public Converter
{
public:
	/** Encoding/decoding scheme. */
	enum EncodingType
	{
		/** Unsupported/unknown encoding. */
		ENCODING_UNKNOWN,
		/** US/ASCII */
		ENCODING_ASCII7,
		/** UTF-8 */
		ENCODING_UTF8,
		/** UTF-16, platform endian */
		ENCODING_UTF16,
		/** UTF-16 Big Endian */
		ENCODING_UTF16BE,
		/** UTF-16 Little Endian */
		ENCODING_UTF16LE,
		/** UTF-32, platform endian */
		ENCODING_UTF32,
		/** UTF-32 Big Endian */
		ENCODING_UTF32BE,
		/** UTF-32 Little Endian */
		ENCODING_UTF32LE
	};
	
	/** 
	 * Creates an UTF-encoding converter with specified encoding.
	 */
	explicit UTFConverter( EncodingType encoding );

	/** 
	 * Decodes bytes to single Unicode code point. 
	 * Ignores invalid input byte sequences.
	 *
	 * @param src Ptr to the source data.
	 * @param srcend Ptr to the end of source data.
	 * @param srcbytes [out] Receives number of bytes decoded.
	 * @param dst [out] Receives decoded Unicode code point (if byte sequence was not malformed).
	 * @return false if decoded byte sequence was malformed.
	 */
	bool	decode( const void* src, const void* srcend, int* srcbytes, int* dst ) const;

	/** 
	 * Encodes single Unicode code point to bytes. 
	 *
	 * @param dst Destination buffer which receives encoded byte sequence.
	 * @param dstend End of the destination buffer.
	 * @param dstbytes [out] Receives number of bytes encoded.
	 * @param src Unicode code point to encode.
	 * @return false if the code point couldn't be encoded.
	 */
	bool	encode( void* dst, void* dstend, int* dstbytes, int src ) const;

private:
	EncodingType	m_type;
};


} // lang


#endif // _LANG_UTFCONVERTER_H


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?