MCPcopy Create free account
hub / github.com/Apache553/SubtitleFontHelper / WideToUtf8String

Function WideToUtf8String

FontLoadInterceptor/RpcClient.cpp:169–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167 }
168
169 std::string WideToUtf8String(const std::wstring& wStr)
170 {
171 std::string ret;
172 const int length = WideCharToMultiByte(
173 CP_UTF8,
174 WC_ERR_INVALID_CHARS,
175 wStr.c_str(),
176 static_cast<int>(wStr.size()),
177 nullptr,
178 0,
179 nullptr,
180 nullptr);
181 if (length <= 0)
182 throw std::runtime_error("WideCharToMultiByte failed");
183 ret.resize(length);
184 WideCharToMultiByte(
185 CP_UTF8,
186 WC_ERR_INVALID_CHARS,
187 wStr.c_str(),
188 static_cast<int>(wStr.size()),
189 ret.data(),
190 length,
191 nullptr,
192 nullptr);
193 return ret;
194 }
195
196 std::wstring Utf8ToWideString(const std::string& str)
197 {

Callers 4

QueryFontFunction · 0.85
TryLoadFunction · 0.85
AppendFontFaceMethod · 0.85
SaveLruCacheMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected