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