OLD | NEW |
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion(); | 46 std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion(); |
47 return osvi->dwMajorVersion >= 6; | 47 return osvi->dwMajorVersion >= 6; |
48 } | 48 } |
49 | 49 |
50 bool IsWindows8OrLater() | 50 bool IsWindows8OrLater() |
51 { | 51 { |
52 std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion(); | 52 std::unique_ptr<OSVERSIONINFOEX> osvi = GetWindowsVersion(); |
53 return (osvi->dwMajorVersion == 6 && osvi->dwMinorVersion >= 2) || osvi->dwMaj
orVersion > 6; | 53 return (osvi->dwMajorVersion == 6 && osvi->dwMinorVersion >= 2) || osvi->dwMaj
orVersion > 6; |
54 } | 54 } |
55 | 55 |
| 56 std::wstring ToWstring(const BSTR b) |
| 57 { |
| 58 if (!b) |
| 59 { |
| 60 // A null BSTR pointer is considered semantically equal to the zero-length s
tring. |
| 61 return std::wstring(); |
| 62 } |
| 63 return std::wstring(b, ::SysStringLen(b)); |
| 64 } |
| 65 |
56 std::string ToUtf8String(const std::wstring& str) | 66 std::string ToUtf8String(const std::wstring& str) |
57 { | 67 { |
58 int length = static_cast<int>(str.size()); | 68 int length = static_cast<int>(str.size()); |
59 if (length == 0) | 69 if (length == 0) |
60 return std::string(); | 70 return std::string(); |
61 | 71 |
62 int utf8StringLength = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, 0,
0, 0, 0); | 72 int utf8StringLength = WideCharToMultiByte(CP_UTF8, 0, str.c_str(), length, 0,
0, 0, 0); |
63 if (utf8StringLength == 0) | 73 if (utf8StringLength == 0) |
64 throw std::runtime_error("Failed to determine the required buffer size"); | 74 throw std::runtime_error("Failed to determine the required buffer size"); |
65 | 75 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return L""; | 197 return L""; |
188 } | 198 } |
189 auto queryStringBeginsAt = questionSignPos + 1; | 199 auto queryStringBeginsAt = questionSignPos + 1; |
190 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); | 200 auto endQueryStringPos = url.find(L'#', queryStringBeginsAt); |
191 if (endQueryStringPos == std::wstring::npos) | 201 if (endQueryStringPos == std::wstring::npos) |
192 { | 202 { |
193 endQueryStringPos = url.length(); | 203 endQueryStringPos = url.length(); |
194 } | 204 } |
195 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt
); | 205 return url.substr(queryStringBeginsAt, endQueryStringPos - queryStringBeginsAt
); |
196 } | 206 } |
OLD | NEW |