MCPcopy Create free account
hub / github.com/BYVoid/OpenCC / WideFromUtf8

Function WideFromUtf8

plugins/jieba/tests/JiebaPluginIntegrationTest.cpp:36–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34#include <windows.h>
35
36std::wstring WideFromUtf8(const std::string& text) {
37 if (text.empty()) {
38 return L"";
39 }
40 const int size =
41 MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, nullptr, 0);
42 if (size <= 1) {
43 return L"";
44 }
45 std::wstring wide(static_cast<size_t>(size), L'\0');
46 MultiByteToWideChar(CP_UTF8, 0, text.c_str(), -1, &wide[0], size);
47 wide.resize(static_cast<size_t>(size - 1));
48 return wide;
49}
50
51void CopyRegularFiles(const std::filesystem::path& sourceDir,
52 const std::filesystem::path& targetDir) {

Callers 2

RunProcessWideFunction · 0.70
TEST_FFunction · 0.70

Calls 2

emptyMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected