MCPcopy Create free account
hub / github.com/Snapchat/Valdi / utf16ToUtf8

Function utf16ToUtf8

valdi_core/src/valdi_core/cpp/Text/UTF16Utils.cpp:162–172  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162std::pair<const char*, size_t> utf16ToUtf8(const char16_t* utf16String, size_t len) {
163 thread_local static std::vector<char> tBuffer;
164 auto& buffer = tBuffer;
165 buffer.clear();
166
167 for (std::u16string::size_type i = 0; i < len;) {
168 utf8Encode(utf16Decode(utf16String, i), buffer);
169 }
170
171 return std::make_pair(buffer.data(), buffer.size());
172}
173
174std::pair<const char16_t*, size_t> utf8ToUtf16(const char* utf8String, size_t len) {
175 thread_local static std::vector<char16_t> tBuffer;

Callers 4

makeStringFromUTF16Method · 0.85
utf8StorageMethod · 0.85
newStringUTF16Method · 0.85
valueToDoubleMethod · 0.85

Calls 5

utf8EncodeFunction · 0.85
utf16DecodeFunction · 0.85
clearMethod · 0.65
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected