diff options
author | Michaƫl Zasso <targos@protonmail.com> | 2019-05-19 09:54:52 +0200 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2019-06-01 09:28:34 +0200 |
commit | 5aaa7fee2e4a075d9123b885f9e8cda3de2a780a (patch) | |
tree | 119e5d320745d7381ab225cd6a55aaaf17606b4b /src/inspector/node_string.cc | |
parent | aa8b820aaa4d36085baaf8beb1187b2b9955fffb (diff) | |
download | android-node-v8-5aaa7fee2e4a075d9123b885f9e8cda3de2a780a.tar.gz android-node-v8-5aaa7fee2e4a075d9123b885f9e8cda3de2a780a.tar.bz2 android-node-v8-5aaa7fee2e4a075d9123b885f9e8cda3de2a780a.zip |
tools: update inspector_protocol to 0aafd2
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
PR-URL: https://github.com/nodejs/node/pull/27770
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'src/inspector/node_string.cc')
-rw-r--r-- | src/inspector/node_string.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/inspector/node_string.cc b/src/inspector/node_string.cc index a79df9e817..0d403c66f0 100644 --- a/src/inspector/node_string.cc +++ b/src/inspector/node_string.cc @@ -107,6 +107,22 @@ String fromUTF8(const uint8_t* data, size_t length) { return std::string(reinterpret_cast<const char*>(data), length); } +String fromUTF16(const uint16_t* data, size_t length) { + icu::UnicodeString utf16(reinterpret_cast<const char16_t*>(data), length); + std::string result; + return utf16.toUTF8String(result); +} + +const uint8_t* CharactersUTF8(const String& s) { + return reinterpret_cast<const uint8_t*>(s.data()); +} + +size_t CharacterCount(const String& s) { + icu::UnicodeString utf16 = + icu::UnicodeString::fromUTF8(icu::StringPiece(s.data(), s.length())); + return utf16.countChar32(); +} + } // namespace StringUtil } // namespace protocol } // namespace inspector |