MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / wchar_to_utf8

Method wchar_to_utf8

src/runner/cli_wide.cpp:51–66  ·  view source on GitHub ↗

\brief Convert wide char to UTF-8

Source from the content-addressed store, hash-verified

49
50/// \brief Convert wide char to UTF-8
51std::string CLIWide::wchar_to_utf8(const std::wstring& wstr) {
52 if (wstr.empty()) return std::string();
53
54 int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
55 if (size_needed == 0) {
56 return std::string();
57 }
58
59 std::string strTo(size_needed, 0);
60 int result = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &strTo[0], size_needed, NULL, NULL);
61 if (result == 0) {
62 return std::string();
63 }
64
65 return strTo;
66}
67
68/// \brief Convert UTF-8 to wide char
69std::wstring CLIWide::utf8_to_wchar(const std::string& str) {

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected