Applied backgroundcolors.patch
[TortoiseGit.git] / src / Utils / UnicodeUtils.h
blobee2d15a3e469403442e9226a335b07ecad2ee537
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2009-2013, 2016 - 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 #include "tstring.h"
26 /**
27 * \ingroup Utils
28 * Class to convert strings from/to UTF8 and UTF16.
30 class CUnicodeUtils
32 public:
33 CUnicodeUtils() = delete;
34 #if defined(_MFC_VER) || defined(CSTRING_AVAILABLE)
35 static CStringA GetUTF8(const CStringW& string);
36 static CStringA GetMulti(const CStringW& string, int acp);
37 static CStringA GetUTF8(const CStringA& string);
38 static CString GetUnicode(const CStringA& string, int acp=CP_UTF8);
39 static int GetCPCode(const CString & codename);
40 #endif
41 #ifdef UNICODE
42 static std::string StdGetUTF8(const std::wstring& wide);
43 static std::wstring StdGetUnicode(const std::string& multibyte);
44 #else
45 static std::string StdGetUTF8(std::string str) {return str;}
46 static std::string StdGetUnicode(std::string multibyte) {return multibyte;}
47 #endif
50 std::string WideToMultibyte(const std::wstring& wide);
51 std::string WideToUTF8(const std::wstring& wide);
52 std::wstring MultibyteToWide(const std::string& multibyte);
53 std::wstring UTF8ToWide(const std::string& multibyte);
55 #ifdef UNICODE
56 std::wstring UTF8ToString(const std::string& string);
57 std::string StringToUTF8(const std::wstring& string);
58 #else
59 std::wstring UTF8ToString(const std::string& string);
60 std::string StringToUTF8(const std::wstring& string);
61 #endif
63 int LoadStringEx(HINSTANCE hInstance, UINT uID, LPTSTR lpBuffer, int nBufferMax, WORD wLanguage);