| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 if (length == 0) | 74 if (length == 0) |
| 75 return std::wstring(); | 75 return std::wstring(); |
| 76 | 76 |
| 77 int utf16StringLength = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, N
ULL, 0); | 77 int utf16StringLength = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, N
ULL, 0); |
| 78 if (utf16StringLength == 0) | 78 if (utf16StringLength == 0) |
| 79 throw std::runtime_error("ToUTF16String failed. Can't determine the length o
f the buffer needed."); | 79 throw std::runtime_error("ToUTF16String failed. Can't determine the length o
f the buffer needed."); |
| 80 | 80 |
| 81 std::wstring utf16String(utf16StringLength, L'\0'); | 81 std::wstring utf16String(utf16StringLength, L'\0'); |
| 82 MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, &utf16String[0], utf16Str
ingLength); | 82 MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, &utf16String[0], utf16Str
ingLength); |
| 83 return utf16String; | 83 return utf16String; |
| 84 } |
| 85 |
| 86 std::vector<std::wstring> ToUtf16Strings(const std::vector<std::string>& values) |
| 87 { |
| 88 std::vector<std::wstring> result; |
| 89 result.reserve(values.size()); |
| 90 transform(values.begin(), values.end(), back_inserter(result), ToUtf16String); |
| 91 return result; |
| 84 } | 92 } |
| 85 | 93 |
| 86 std::wstring GetDllDir() | 94 std::wstring GetDllDir() |
| 87 { | 95 { |
| 88 std::vector<WCHAR> path(MAX_PATH); | 96 std::vector<WCHAR> path(MAX_PATH); |
| 89 int length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], static_cast
<DWORD>(path.size())); | 97 int length = GetModuleFileNameW((HINSTANCE)&__ImageBase, &path[0], static_cast
<DWORD>(path.size())); |
| 90 | 98 |
| 91 while (length == path.size()) | 99 while (length == path.size()) |
| 92 { | 100 { |
| 93 // Buffer too small, double buffer size | 101 // Buffer too small, double buffer size |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 { | 173 { |
| 166 return L""; | 174 return L""; |
| 167 } | 175 } |
| 168 auto queryStringBeginsAt = questionSignPos + 1; | 176 auto queryStringBeginsAt = questionSignPos + 1; |
| 169 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); | 177 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); |
| 170 if (endQueryStringPos == std::wstring::npos) | 178 if (endQueryStringPos == std::wstring::npos) |
| 171 { | 179 { |
| 172 endQueryStringPos = url.length(); | 180 endQueryStringPos = url.length(); |
| 173 } | 181 } |
| 174 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt
); | 182 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt
); |
| 175 } | 183 } |
| LEFT | RIGHT |