25 #include <boost/algorithm/string.hpp>
30 #pragma warning(disable:4267) // '?' : conversion from 'A' to 'B', possible loss of data
35 std::string
resolve_path(
const std::string& filePath, std::string sourcePath)
40 std::size_t slashPos = sourcePath.find_last_of(
"/");
41 if(slashPos == std::string::npos)
43 sourcePath = sourcePath.substr(0, slashPos + 1);
45 return sourcePath + filePath;
53 std::tm *ts = std::localtime(&tnow);
54 std::strftime(date, 32,
"%b %d %Y %H:%M:%S", ts);
55 return std::string(date);
70 std::istringstream i(str);
77 const unsigned char *bytes = (
const unsigned char *)src.c_str();
84 (0x20 <= bytes[0] && bytes[0] <= 0x7E)
91 (0xC2 <= bytes[0] && bytes[0] <= 0xDF) &&
92 (0x80 <= bytes[1] && bytes[1] <= 0xBF)
100 (0xA0 <= bytes[1] && bytes[1] <= 0xBF) &&
101 (0x80 <= bytes[2] && bytes[2] <= 0xBF)
104 ((0xE1 <= bytes[0] && bytes[0] <= 0xEC) ||
107 (0x80 <= bytes[1] && bytes[1] <= 0xBF) &&
108 (0x80 <= bytes[2] && bytes[2] <= 0xBF)
112 (0x80 <= bytes[1] && bytes[1] <= 0x9F) &&
113 (0x80 <= bytes[2] && bytes[2] <= 0xBF)
121 (0x90 <= bytes[1] && bytes[1] <= 0xBF) &&
122 (0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
123 (0x80 <= bytes[3] && bytes[3] <= 0xBF)
126 (0xF1 <= bytes[0] && bytes[0] <= 0xF3) &&
127 (0x80 <= bytes[1] && bytes[1] <= 0xBF) &&
128 (0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
129 (0x80 <= bytes[3] && bytes[3] <= 0xBF)
133 (0x80 <= bytes[1] && bytes[1] <= 0x8F) &&
134 (0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
135 (0x80 <= bytes[3] && bytes[3] <= 0xBF)
149 for(
uint i=0;i<src.length();) {
151 if((c >= 32 && c < 128) || c == 0x0d || c == 0x0a || c == 0x09)
153 else if(c == 0xc2 || c == 0xc3) {
156 if(c2 > 0xa1 && c2 < 0xbb)
160 }
else if(c >= 0xc4 && c <= 0xdf)
162 else if(c >= 0xe0 && c <= 0xed)
164 else if(c >= 0xf0 && c <= 0xf4)
174 if((c >= 32 && c < 128) || c == 0x0d || c == 0x0a || c == 0x09)
177 out += 0xc2 + (c > 0xbf);
178 out += 0x80 + (c & 0x3f);
185 #include <winsock2.h>
187 std::wstring utf8_to_utf16(
const std::string& src)
191 if(MultiByteToWideChar(CP_UTF8, 0, src.c_str(), -1, out, 4096))
196 std::string utf16_to_utf8(
const std::wstring& src)
200 if(WideCharToMultiByte(CP_UTF8, 0, src.c_str(), -1, out, 4096, NULL, NULL))
205 std::wstring latin1_to_utf16(
const std::string& src)
210 std::string utf16_to_latin1(
const std::wstring& src)
218 std::transform(str.begin(), str.end(), str.begin(),
lochar);
223 std::transform(str.begin(), str.end(), str.begin(),
upchar);
233 if((c >= 97 && c <= 122) || (
uchar)c >= 224)
240 if((c >= 65 && c <= 90) || ((
uchar)c >= 192 && (
uchar)c <= 223))
247 uint32 strLen = str.length();
252 for(
uint32 i = 1; i < strLen; ++i) {
253 if(str[i - 1] ==
' ')
258 bool ends_with(
const std::string& str,
const std::string& test)
268 void replace_all(std::string& str,
const std::string& search,
const std::string& replacement)
273 std::vector<std::string>
split(
const std::string& str,
const std::string& separators)
275 std::vector<std::string> splitted;
276 boost::split(splitted, str, boost::is_any_of(std::string(separators)));