MCPcopy Create free account
hub / github.com/SOUI2/soui / WString2String

Function WString2String

components/resprovider-7zip/Zip7Archive.cpp:46–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45
46static std::string WString2String(const std::wstring &wstr)
47{
48 int len = wstr.length();
49 const wchar_t *pStr = wstr.c_str();
50 std::string buf;
51
52
53 if (len < 0 && len != -1)
54 {
55 return buf;
56 }
57
58 // figure out how many narrow characters we are going to get
59 int nChars = WideCharToMultiByte(CP_ACP, 0, pStr, len, NULL, 0, NULL, NULL);
60 if (len == -1)
61 --nChars;
62 if (nChars == 0)
63 return "";
64
65 // convert the wide string to a narrow string
66 // nb: slightly naughty to write directly into the string like this
67 buf.resize(nChars);
68 WideCharToMultiByte(CP_ACP, 0, pStr, len, const_cast<char*>(buf.c_str()), nChars, NULL, NULL);
69
70 return buf;
71}
72
73
74 CZipFile::CZipFile(DWORD dwSize/*=0*/)

Callers 2

GetFileMethod · 0.85
GetFileSizeMethod · 0.85

Calls 3

lengthMethod · 0.45
c_strMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected