| 44 | |
| 45 | |
| 46 | static 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*/) |
no test coverage detected