• Main Page
  • Classes
  • Files
  • File List

CUnicode.h

00001 /*
00002  * synergy -- mouse and keyboard sharing utility
00003  * Copyright (C) 2012 Bolton Software Ltd.
00004  * Copyright (C) 2002 Chris Schoeneman
00005  * 
00006  * This package is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * found in the file COPYING that should have accompanied this file.
00009  * 
00010  * This package is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
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     // convert UTF8 to wchar_t string (using whatever encoding is native
00121     // to the platform).  caller must delete[] the returned string.  the
00122     // string is *not* nul terminated;  the length (in characters) is
00123     // returned in size.
00124     static wchar_t*     UTF8ToWideChar(const CString&,
00125                             UInt32& size, bool* errors);
00126 
00127     // convert nul terminated wchar_t string (in platform's native
00128     // encoding) to UTF8.
00129     static CString      wideCharToUTF8(const wchar_t*,
00130                             UInt32 size, bool* errors);
00131 
00132     // internal conversion to UTF8
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     // convert characters to/from UTF8
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

Generated on Sun May 26 2013 00:00:05 for Synergy by  doxygen 1.7.1