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

Method utf8ToWString

valdi_core/src/valdi_core/cpp/Utils/StaticString.cpp:208–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

206}
207
208std::wstring StaticString::utf8ToWString(std::string_view str) {
209 static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "wchar_t must be 2 or 4 bytes");
210 if constexpr (sizeof(wchar_t) == 2) {
211 auto pair = utf8ToUtf16(str.data(), str.size());
212 return std::wstring(reinterpret_cast<const wchar_t*>(pair.first), pair.second);
213 } else {
214 auto pair = utf8ToUtf32(str.data(), str.size());
215 return std::wstring(reinterpret_cast<const wchar_t*>(pair.first), pair.second);
216 }
217}
218
219std::ostream& operator<<(std::ostream& os, const StaticString& value) {
220 auto storage = value.utf8Storage();

Callers

nothing calls this directly

Calls 4

utf8ToUtf16Function · 0.85
utf8ToUtf32Function · 0.85
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected