OSDN Git Service

Add pull and fetch document
[tortoisegit/TortoiseGitJp.git] / src / Utils / UnicodeUtils.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2007 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 #include <string>\r
22 #include <WinDef.h>\r
23 #pragma warning (push,1)\r
24 #ifndef stdstring\r
25         typedef std::wstring wide_string;\r
26 #       ifdef UNICODE\r
27 #               define stdstring wide_string\r
28 #       else\r
29 #               define stdstring std::string\r
30 #       endif\r
31 #endif\r
32 #pragma warning (pop)\r
33 \r
34 /**\r
35  * \ingroup Utils\r
36  * Class to convert strings from/to UTF8 and UTF16.\r
37  */\r
38 class CUnicodeUtils\r
39 {\r
40 public:\r
41         CUnicodeUtils(void);\r
42         ~CUnicodeUtils(void);\r
43 #if defined(_MFC_VER) || defined(CSTRING_AVAILABLE)\r
44         static CStringA GetUTF8(const CStringW& string);\r
45         static CStringA GetUTF8(const CStringA& string);\r
46         static CString GetUnicode(const CStringA& string);\r
47         static CStringA ConvertWCHARStringToUTF8(const CString& string);\r
48         static int GetCPCode(CString & codename);\r
49 #endif\r
50 #ifdef UNICODE\r
51         static std::string StdGetUTF8(const wide_string& wide);\r
52         static wide_string StdGetUnicode(const std::string& multibyte);\r
53 #else\r
54         static std::string StdGetUTF8(std::string str) {return str;}\r
55         static std::string StdGetUnicode(std::string multibyte) {return multibyte;}\r
56 #endif\r
57 };\r
58 \r
59 std::string WideToMultibyte(const wide_string& wide);\r
60 std::string WideToUTF8(const wide_string& wide);\r
61 wide_string MultibyteToWide(const std::string& multibyte);\r
62 wide_string UTF8ToWide(const std::string& multibyte);\r
63 \r
64 #ifdef UNICODE\r
65         stdstring UTF8ToString(const std::string& string); \r
66         std::string StringToUTF8(const stdstring& string); \r
67 #else\r
68         stdstring UTF8ToString(const std::string& string); \r
69         std::string StringToUTF8(const stdstring& string);\r
70 #endif\r
71 \r
72 int LoadStringEx(HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer, int nBufferMax, WORD wLanguage);\r