MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / UTF8Encode

Method UTF8Encode

external/ImGuiFileDialog/ImGuiFileDialog.cpp:936–951  ·  view source on GitHub ↗

Convert a wide Unicode string to an UTF8 string

Source from the content-addressed store, hash-verified

934
935// Convert a wide Unicode string to an UTF8 string
936std::string IGFD::Utils::UTF8Encode(const std::wstring& wstr) {
937 std::string res;
938#ifdef _IGFD_WIN_
939 if (!wstr.empty()) {
940 int size_needed = WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), nullptr, 0, nullptr, nullptr);
941 if (size_needed) {
942 res = std::string(size_needed, 0);
943 WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &res[0], size_needed, nullptr, nullptr);
944 }
945 }
946#else
947 // Suppress warnings from the compiler.
948 (void)wstr;
949#endif // _IGFD_WIN_
950 return res;
951}
952
953// Convert an UTF8 string to a wide Unicode String
954std::wstring IGFD::Utils::UTF8Decode(const std::string& str) {

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected