00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CUNICODE_H
00016 #define CUNICODE_H
00017
00018 #include "CString.h"
00019 #include "BasicTypes.h"
00020
00022
00026 class CUnicode {
00027 public:
00029
00030
00032
00036 static bool isUTF8(const CString&);
00037
00039
00044 static CString UTF8ToUCS2(const CString&, bool* errors = NULL);
00045
00047
00052 static CString UTF8ToUCS4(const CString&, bool* errors = NULL);
00053
00055
00060 static CString UTF8ToUTF16(const CString&, bool* errors = NULL);
00061
00063
00068 static CString UTF8ToUTF32(const CString&, bool* errors = NULL);
00069
00071
00076 static CString UTF8ToText(const CString&, bool* errors = NULL);
00077
00079
00083 static CString UCS2ToUTF8(const CString&, bool* errors = NULL);
00084
00086
00090 static CString UCS4ToUTF8(const CString&, bool* errors = NULL);
00091
00093
00097 static CString UTF16ToUTF8(const CString&, bool* errors = NULL);
00098
00100
00104 static CString UTF32ToUTF8(const CString&, bool* errors = NULL);
00105
00107
00111 static CString textToUTF8(const CString&, bool* errors = NULL);
00112
00114
00115 private:
00116
00117
00118
00119
00120 static wchar_t* UTF8ToWideChar(const CString&,
00121 UInt32& size, bool* errors);
00122
00123
00124
00125 static CString wideCharToUTF8(const wchar_t*,
00126 UInt32 size, bool* errors);
00127
00128
00129 static CString doUCS2ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00130 static CString doUCS4ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00131 static CString doUTF16ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00132 static CString doUTF32ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00133
00134
00135 static UInt32 fromUTF8(const UInt8*& src, UInt32& size);
00136 static void toUTF8(CString& dst, UInt32 c, bool* errors);
00137
00138 private:
00139 static UInt32 s_invalid;
00140 static UInt32 s_replacement;
00141 };
00142
00143 #endif