/*! \addtogroup UNICODE * @{ */ /*! * * @file unicode.h * * @brief This file specifies the Unicode translation APIs * * @note Copyright (c) 2009 Sunplus Technology Co., Ltd. \n * All rights reserved. * * @author * ******************************************************************************/ #ifndef __UNICODE_CODE_PAGE_H__ #define __UNICODE_CODE_PAGE_H__ /******************************************************************************/ /*! * @brief Enumeration of all supported Unicode code pages * * @note Because codepages BIG5 and GB2312 can be replaced with CP950 and CP936, * BIG5 and GB2312 codepages are removed. * But uiDesign tool has used name "BIG5" and "GB2312" in its codebase, * it is not suggested to remove these two codepage name here. (by mandy.wu) * Everyone is still able to use these 2 codepages, but it will be transferred * to call CP950 and CP936 translations inside UNI_Utf162Chr() and UNI_Chr2Utf16() APIs. * -- nicholas.lin 09-09-09 *******************************************************************************/ typedef enum { CP_437 = 0, // 0 CP_932, // 1 CP_936, // 2 CP_950, // 3 CP_1250, // 4 CP_1251, // 5 CP_1252, // 6 CP_1253, // 7 CP_1254, // 8 CP_1255, // 9 CP_1256, // 10 CP_1257, // 11 CP_1258, // 12 CP_8256, // 13 CP_8257, // 14 CP_8258, // 15 BIG5, // 16 GB2312, // 17 KSC5601, // 18 ISO6937, // 19 ISO8859_1, // 20 ISO8859_2, // 21 ISO8859_3, // 22 ISO8859_4, // 23 ISO8859_5, // 24 ISO8859_6, // 25 ISO8859_7, // 26 ISO8859_8, // 27 ISO8859_9, // 28 ISO8859_10, // 29 ISO8859_11, // 30 ISO8859_12, // 31 ISO8859_13, // 32 ISO8859_14, // 33 ISO8859_15, // 34 ISO8859_16, // 35 UTF8, // 36 UNICODE, // 37 UTF16_LE, //38 UTF16_BE, //39 CP_874, // 40 CODE_PAGE_MAX //ENCODETYPE_AUTO }UNICODE_SUPPORT_CODE_PAGE; /*! * @defgroup Unicode Unicode character and string translation APIs * @brief Unicode Unicode character and string translation APIs * @{ */ /******************************************************************************/ /*! * @brief Translation from unicode(UTF-16) to native code * * @param codepage native code page * @param uni source unicode character * @param out output native code character * * @return @a length of output native code character in bytes * @return @a -1 on failure * * @note Use UINT16 array to store unicode strings instead of UINT8 array *******************************************************************************/ INT32 UNI_Utf162Chr(const UINT32 codepage, const UINT16 uni, UINT8 *out); /******************************************************************************/ /*! * @brief Translation from native code to unicode(UTF-16) * * @param codepage native code page * @param rawchr source native code character * @param uni output unicode character * * @return @a length of output unicodecode character in bytes * @return @a -1 on failure * * @note Use UINT16 array to store unicode strings instead of UINT8 array *******************************************************************************/ INT32 UNI_Chr2Utf16(const UINT32 codepage, const UINT8 *rawchr, UINT16 *uni); /******************************************************************************/ /*! * @brief Translate a UTF-16 coded string to UTF-8 coded string * * @param src pointer of source UTF-16 coded string * @param srcLen string length of source UTF-16 coded string in dual-bytes. * @param dest pointer to destination UTF-8 coded string * @param destLen return value of string length of destination UTF-8 coded string in bytes * * @return @a 0 on success * @return @a -1 on failure * * @note Use UINT16 array to store UTF-16 strings instead of UINT8 array; * @note currently we can only process 16-bit length UTF-16 string; *******************************************************************************/ INT32 UNI_Utf16S2Utf8S(const UINT16 *src, const UINT32 srcLen, UINT8 *dest, UINT32 *destLen); /******************************************************************************/ /*! * @brief Translate a UTF-8 coded string to UTF-16 coded string * * @param src pointer of source UTF-8 coded string * @param srcLen string length of source UTF-8 coded string in bytes. * @param dest pointer to destination UTF-16 coded string * @param destLen return value of string length of destination UTF-16 coded string in dual-bytes * * @return @a 0 on success * @return @a -1 on failure * * @note Use UINT16 array to store UTF-16 strings instead of UINT8 array; * @note currently we can only process 16-bit length UTF-16 string; *******************************************************************************/ INT32 UNI_Utf8S2Utf16S(const UINT8 *src, const UINT32 srcLen, UINT16 *dest, UINT32 *destLen); /******************************************************************************/ /*! * @brief Translation from UTF-16 character to UTF-8 character * * @param utf16 source UTF-16 character * @param utf8 output UTF-8 character * * @return @a length of output UTF-8 character in bytes * @return @a -1 on failure * * @note Use UINT16 array to store UTF-16 strings instead of UINT8 array *******************************************************************************/ INT32 UNI_Utf162Utf8(const UINT16 utf16, UINT8 *utf8); /******************************************************************************/ /*! * @brief Translation from UTF-8 character to UTF-16 character * * @param utf8 source UTF-8 character * @param utf16 output UTF-16 character * * @return @a length of source UTF-8 character in bytes * @return @a -1 on failure * * @note Use UINT16 array to store UTF-16 strings instead of UINT8 array *******************************************************************************/ INT32 UNI_Utf82Utf16(const UINT8 *utf8, UINT16 *utf16); #ifdef CONFIG_SUPPORT_CHARSETDET /******************************************************************************/ /*! * @brief Guess a codepage by a raw character stream * * @param rawchr raw character stream * @param size of raw character stream * * @return guessed code page number *******************************************************************************/ UINT32 UNI_GuessCodePage(const UINT8 *rawchr, UINT32 size); UINT32 UNI_FontType2CodePage(UINT32 font); #endif UINT8* UNI_StringToUtf8(UINT32 codepage, UINT8* string_ptr, INT32* len_ptr, bool skip_ctrl); void UNI_GetUTF8EncodeSize(UINT8 *pString, UINT16 *pEncodeSize); UINT8* UNI_SetUTF8Position(UINT8 *pString, INT32 *pLen, UINT32 *pPosition); INT32 UNI_GetCodePage(UINT32 *pCodePage, UINT8 *rawchr, INT32 *size); /*! @} end of defgroup Unicode */ #endif // __UNICODE_CODE_PAGE_H__ /*! @} end of addtogroup UNICODE */