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

Method WideToUtf8String

SubtitleFontAutoLoaderDaemon/Common.cpp:10–34  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8#include <wil/resource.h>
9
10std::string sfh::WideToUtf8String(const std::wstring& wStr)
11{
12 std::string ret;
13 const int length = WideCharToMultiByte(
14 CP_UTF8,
15 WC_ERR_INVALID_CHARS,
16 wStr.c_str(),
17 static_cast<int>(wStr.size()),
18 nullptr,
19 0,
20 nullptr,
21 nullptr);
22 assert(length != 0 && "wide char conversion to utf8 mustn't fail!");
23 ret.resize(length);
24 WideCharToMultiByte(
25 CP_UTF8,
26 WC_ERR_INVALID_CHARS,
27 wStr.c_str(),
28 static_cast<int>(wStr.size()),
29 ret.data(),
30 length,
31 nullptr,
32 nullptr);
33 return ret;
34}
35
36std::wstring sfh::Utf8ToWideString(const std::string& str)
37{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected