BuildCache
unicode_utils.hpp
1 //--------------------------------------------------------------------------------------------------
2 // Copyright (c) 2018 Marcus Geelnard
3 //
4 // This software is provided 'as-is', without any express or implied warranty. In no event will the
5 // authors be held liable for any damages arising from the use of this software.
6 //
7 // Permission is granted to anyone to use this software for any purpose, including commercial
8 // applications, and to alter it and redistribute it freely, subject to the following restrictions:
9 //
10 // 1. The origin of this software must not be misrepresented; you must not claim that you wrote
11 // the original software. If you use this software in a product, an acknowledgment in the
12 // product documentation would be appreciated but is not required.
13 //
14 // 2. Altered source versions must be plainly marked as such, and must not be misrepresented as
15 // being the original software.
16 //
17 // 3. This notice may not be removed or altered from any source distribution.
18 //--------------------------------------------------------------------------------------------------
19 
20 #ifndef BUILDCACHE_UNICODE_UTILS_HPP_
21 #define BUILDCACHE_UNICODE_UTILS_HPP_
22 
23 #include <string>
24 
25 namespace bcache {
29 std::string ucs2_to_utf8(const std::wstring& str16);
30 
35 std::string ucs2_to_utf8(const wchar_t* begin, const wchar_t* end);
36 
40 std::wstring utf8_to_ucs2(const std::string& str8);
41 
46 int lower_case(const int code);
47 
52 int upper_case(const int code);
53 
58 std::string lower_case(const std::string& str);
59 
64 std::string upper_case(const std::string& str);
65 
69 std::string lstrip(const std::string& str);
70 
74 std::string rstrip(const std::string& str);
75 
79 std::string strip(const std::string& str);
80 } // namespace bcache
81 
82 #endif // BUILDCACHE_UNICODE_UTILS_HPP_
bcache::utf8_to_ucs2
std::wstring utf8_to_ucs2(const std::string &str8)
Convert a UTF-8 string to a UCS-2 string.
Definition: unicode_utils.cpp:145
bcache::ucs2_to_utf8
std::string ucs2_to_utf8(const std::wstring &str16)
Convert a UCS-2 string to a UTF-8 string.
Definition: unicode_utils.cpp:124
bcache
The top level namespace.
Definition: compressor.cpp:34
bcache::strip
std::string strip(const std::string &str)
Strip leading and trailing white space characters.
Definition: unicode_utils.cpp:243
bcache::rstrip
std::string rstrip(const std::string &str)
Strip trailing white space characters.
Definition: unicode_utils.cpp:234
bcache::lower_case
int lower_case(const int code)
Convert the character to lower case.
Definition: unicode_utils.cpp:191
bcache::lstrip
std::string lstrip(const std::string &str)
Strip leading white space characters.
Definition: unicode_utils.cpp:225
bcache::upper_case
int upper_case(const int code)
Convert the character to upper case.
Definition: unicode_utils.cpp:199