194943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu/*!**************************************************************************** 294943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu 394943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @file PVRTUnicode.h 494943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @copyright Copyright (c) Imagination Technologies Limited. 594943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @brief A small collection of functions used to decode Unicode formats to 694943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu individual code points. 794943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu 894943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu******************************************************************************/ 994943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu#ifndef _PVRTUNICODE_H_ 10d2592a34a059e7cbb2b11dc53649ac4912422909Argyrios Kyrtzidis#define _PVRTUNICODE_H_ 1194943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu 1294943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu#include "PVRTGlobal.h" 1394943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu#include "PVRTError.h" 1494943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu#include "PVRTArray.h" 15bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis 16ec8605f1d7ec846dbf51047bfd5c56d32d1ff91cArgyrios Kyrtzidis/**************************************************************************** 17bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis** Functions 18bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis****************************************************************************/ 199b663716449b618ba0390b1dbebc54fa8e971124Ted Kremenek 2094943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu/*!*************************************************************************** 2194943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @brief Decodes a UTF8-encoded string in to Unicode code points 229ef6537a894c33003359b1f9b9676e9178e028b7Ted Kremenek (UTF32). If pUTF8 is not null terminated, the results are 2394943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu undefined. 24f493f49fae3ab242ae055ae00b24fa5512655e15Ted Kremenek @param[in] pUTF8 A UTF8 string, which is null terminated. 25ba5fb5a955c896815c439289fc51c03cf0635129Kovarththanan Rajaratnam @param[out] aUTF32 An array of Unicode code points. 26ec8605f1d7ec846dbf51047bfd5c56d32d1ff91cArgyrios Kyrtzidis @return Success or failure. 27bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis*****************************************************************************/ 28f493f49fae3ab242ae055ae00b24fa5512655e15Ted KremenekEPVRTError PVRTUnicodeUTF8ToUTF32( const PVRTuint8* const pUTF8, CPVRTArray<PVRTuint32>& aUTF32); 29bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis 30bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis/*!*************************************************************************** 31f493f49fae3ab242ae055ae00b24fa5512655e15Ted Kremenek @brief Decodes a UTF16-encoded string in to Unicode code points 32f493f49fae3ab242ae055ae00b24fa5512655e15Ted Kremenek (UTF32). If pUTF16 is not null terminated, the results are 33f493f49fae3ab242ae055ae00b24fa5512655e15Ted Kremenek undefined. 34bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis @param[in] pUTF16 A UTF16 string, which is null terminated. 35bd90076671c8012244bb7e3fd84b6789e47cb199Argyrios Kyrtzidis @param[out] aUTF32 An array of Unicode code points. 3694943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @return Success or failure. 3794943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu*****************************************************************************/ 3894943b6d913718216a95a91864040ffc11a1d779Zhongxing XuEPVRTError PVRTUnicodeUTF16ToUTF32(const PVRTuint16* const pUTF16, CPVRTArray<PVRTuint32>& aUTF32); 391397663af9dbcc24dbf0e11de43931b3dc08fdbbTed Kremenek 4094943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu/*!*************************************************************************** 4194943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @brief Calculates the length of a UTF8 string. If pUTF8 is 4294943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu not null terminated, the results are undefined. 4394943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @param[in] pUTF8 A UTF8 string, which is null terminated. 4494943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @return The length of the string, in Unicode code points. 4594943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu*****************************************************************************/ 4694943b6d913718216a95a91864040ffc11a1d779Zhongxing Xuunsigned int PVRTUnicodeUTF8Length(const PVRTuint8* const pUTF8); 4794943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu 4894943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu/*!*************************************************************************** 4994943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @brief Calculates the length of a UTF16 string. 5094943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu If pUTF16 is not null terminated, the results are 5194943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu undefined. 5294943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @param[in] pUTF16 A UTF16 string, which is null terminated. 5394943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu @return The length of the string, in Unicode code points. 5494943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu*****************************************************************************/ 5594943b6d913718216a95a91864040ffc11a1d779Zhongxing Xuunsigned int PVRTUnicodeUTF16Length(const PVRTuint16* const pUTF16); 5694943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu 5794943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu/*!*************************************************************************** 589a126850968b0aa25f7c6f214e7309e33f2d800aJordy Rose @brief Checks whether the encoding of a UTF8 string is valid. 599a126850968b0aa25f7c6f214e7309e33f2d800aJordy Rose If pUTF8 is not null terminated, the results are undefined. 609a126850968b0aa25f7c6f214e7309e33f2d800aJordy Rose @param[in] pUTF8 A UTF8 string, which is null terminated. 619a126850968b0aa25f7c6f214e7309e33f2d800aJordy Rose @return true or false 629a126850968b0aa25f7c6f214e7309e33f2d800aJordy Rose*****************************************************************************/ 639a126850968b0aa25f7c6f214e7309e33f2d800aJordy Rosebool PVRTUnicodeValidUTF8(const PVRTuint8* const pUTF8); 6494943b6d913718216a95a91864040ffc11a1d779Zhongxing Xu 65bb0ba0bca7896e76f8ce9b709ee881cc505e4d5eTed Kremenek#endif /* _PVRTUNICODE_H_ */ 66bb0ba0bca7896e76f8ce9b709ee881cc505e4d5eTed Kremenek 67bb0ba0bca7896e76f8ce9b709ee881cc505e4d5eTed Kremenek/***************************************************************************** 68bb0ba0bca7896e76f8ce9b709ee881cc505e4d5eTed Kremenek End of file (PVRTUnicode.h) 69bb0ba0bca7896e76f8ce9b709ee881cc505e4d5eTed Kremenek*****************************************************************************/ 70bb0ba0bca7896e76f8ce9b709ee881cc505e4d5eTed Kremenek 71bb0ba0bca7896e76f8ce9b709ee881cc505e4d5eTed Kremenek