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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 std::string Utils::FromV8String(v8::Handle<v8::Value> value) | 37 std::string Utils::FromV8String(v8::Handle<v8::Value> value) |
38 { | 38 { |
39 v8::String::Utf8Value stringValue(value); | 39 v8::String::Utf8Value stringValue(value); |
40 if (stringValue.length()) | 40 if (stringValue.length()) |
41 return std::string(*stringValue, stringValue.length()); | 41 return std::string(*stringValue, stringValue.length()); |
42 else | 42 else |
43 return std::string(); | 43 return std::string(); |
44 } | 44 } |
45 | 45 |
46 v8::Local<v8::String> Utils::ToV8String(const std::string& str) | 46 v8::Local<v8::String> Utils::ToV8String(v8::Isolate* isolate, const std::string&
str) |
47 { | 47 { |
48 return v8::String::New(str.c_str(), str.length()); | 48 return v8::String::NewFromUtf8(isolate, str.c_str(), |
| 49 v8::String::NewStringType::kNormalString, str.length()); |
49 } | 50 } |
50 | 51 |
51 | 52 |
52 #ifdef _WIN32 | 53 #ifdef _WIN32 |
53 std::wstring Utils::ToUtf16String(const std::string& str) | 54 std::wstring Utils::ToUtf16String(const std::string& str) |
54 { | 55 { |
55 size_t length = str.size(); | 56 size_t length = str.size(); |
56 if (length == 0) | 57 if (length == 0) |
57 return std::wstring(); | 58 return std::wstring(); |
58 | 59 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 if (FAILED(hr)) | 97 if (FAILED(hr)) |
97 { | 98 { |
98 throw std::runtime_error("CanonizeUrl failed\n"); | 99 throw std::runtime_error("CanonizeUrl failed\n"); |
99 } | 100 } |
100 } | 101 } |
101 return canonizedUrl; | 102 return canonizedUrl; |
102 | 103 |
103 } | 104 } |
104 #endif | 105 #endif |
105 | 106 |
OLD | NEW |