OSDN Git Service

Change Dir Structure to be same as TortoiseSVN'
[tortoisegit/TortoiseGitJp.git] / src / Utils / UnicodeUtils.h
diff --git a/src/Utils/UnicodeUtils.h b/src/Utils/UnicodeUtils.h
new file mode 100644 (file)
index 0000000..f926a19
--- /dev/null
@@ -0,0 +1,71 @@
+// TortoiseSVN - a Windows shell extension for easy version control\r
+\r
+// Copyright (C) 2003-2007 - TortoiseSVN\r
+\r
+// This program is free software; you can redistribute it and/or\r
+// modify it under the terms of the GNU General Public License\r
+// as published by the Free Software Foundation; either version 2\r
+// of the License, or (at your option) any later version.\r
+\r
+// This program is distributed in the hope that it will be useful,\r
+// but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+// GNU General Public License for more details.\r
+\r
+// You should have received a copy of the GNU General Public License\r
+// along with this program; if not, write to the Free Software Foundation,\r
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
+//\r
+#pragma once\r
+\r
+#include <string>\r
+#include <WinDef.h>\r
+#pragma warning (push,1)\r
+#ifndef stdstring\r
+       typedef std::wstring wide_string;\r
+#      ifdef UNICODE\r
+#              define stdstring wide_string\r
+#      else\r
+#              define stdstring std::string\r
+#      endif\r
+#endif\r
+#pragma warning (pop)\r
+\r
+/**\r
+ * \ingroup Utils\r
+ * Class to convert strings from/to UTF8 and UTF16.\r
+ */\r
+class CUnicodeUtils\r
+{\r
+public:\r
+       CUnicodeUtils(void);\r
+       ~CUnicodeUtils(void);\r
+#if defined(_MFC_VER) || defined(CSTRING_AVAILABLE)\r
+       static CStringA GetUTF8(const CStringW& string);\r
+       static CStringA GetUTF8(const CStringA& string);\r
+       static CString GetUnicode(const CStringA& string);\r
+       static CStringA ConvertWCHARStringToUTF8(const CString& string);\r
+#endif\r
+#ifdef UNICODE\r
+       static std::string StdGetUTF8(const wide_string& wide);\r
+       static wide_string StdGetUnicode(const std::string& multibyte);\r
+#else\r
+       static std::string StdGetUTF8(std::string str) {return str;}\r
+       static std::string StdGetUnicode(std::string multibyte) {return multibyte;}\r
+#endif\r
+};\r
+\r
+std::string WideToMultibyte(const wide_string& wide);\r
+std::string WideToUTF8(const wide_string& wide);\r
+wide_string MultibyteToWide(const std::string& multibyte);\r
+wide_string UTF8ToWide(const std::string& multibyte);\r
+\r
+#ifdef UNICODE\r
+       stdstring UTF8ToString(const std::string& string); \r
+       std::string StringToUTF8(const stdstring& string); \r
+#else\r
+       stdstring UTF8ToString(const std::string& string); \r
+       std::string StringToUTF8(const stdstring& string);\r
+#endif\r
+\r
+int LoadStringEx(HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer, int nBufferMax, WORD wLanguage);\r