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