00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CUNICODE_H
00020 #define CUNICODE_H
00021
00022 #include "CString.h"
00023 #include "BasicTypes.h"
00024
00026
00030 class CUnicode {
00031 public:
00033
00034
00036
00040 static bool isUTF8(const CString&);
00041
00043
00048 static CString UTF8ToUCS2(const CString&, bool* errors = NULL);
00049
00051
00056 static CString UTF8ToUCS4(const CString&, bool* errors = NULL);
00057
00059
00064 static CString UTF8ToUTF16(const CString&, bool* errors = NULL);
00065
00067
00072 static CString UTF8ToUTF32(const CString&, bool* errors = NULL);
00073
00075
00080 static CString UTF8ToText(const CString&, bool* errors = NULL);
00081
00083
00087 static CString UCS2ToUTF8(const CString&, bool* errors = NULL);
00088
00090
00094 static CString UCS4ToUTF8(const CString&, bool* errors = NULL);
00095
00097
00101 static CString UTF16ToUTF8(const CString&, bool* errors = NULL);
00102
00104
00108 static CString UTF32ToUTF8(const CString&, bool* errors = NULL);
00109
00111
00115 static CString textToUTF8(const CString&, bool* errors = NULL);
00116
00118
00119 private:
00120
00121
00122
00123
00124 static wchar_t* UTF8ToWideChar(const CString&,
00125 UInt32& size, bool* errors);
00126
00127
00128
00129 static CString wideCharToUTF8(const wchar_t*,
00130 UInt32 size, bool* errors);
00131
00132
00133 static CString doUCS2ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00134 static CString doUCS4ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00135 static CString doUTF16ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00136 static CString doUTF32ToUTF8(const UInt8* src, UInt32 n, bool* errors);
00137
00138
00139 static UInt32 fromUTF8(const UInt8*& src, UInt32& size);
00140 static void toUTF8(CString& dst, UInt32 c, bool* errors);
00141
00142 private:
00143 static UInt32 s_invalid;
00144 static UInt32 s_replacement;
00145 };
00146
00147 #endif