| 168 | } |
| 169 | |
| 170 | char* SU::WCharToChar(const wchar_t * wstring) { |
| 171 | int size = 0; |
| 172 | int ret = 0; |
| 173 | |
| 174 | if (wstring == NULL) |
| 175 | return NULL; |
| 176 | |
| 177 | if (wstring[0] == 0) { |
| 178 | char * empty = new char[1]; |
| 179 | empty[0] = 0; |
| 180 | return empty; |
| 181 | } |
| 182 | |
| 183 | size = ::WideCharToMultiByte(CP_ACP, 0, wstring, -1, NULL, 0, NULL, NULL); |
| 184 | if (size == 0) |
| 185 | return NULL; |
| 186 | |
| 187 | char * string = new char[size]; |
| 188 | ret = ::WideCharToMultiByte(CP_ACP, 0, wstring, -1, string, size, NULL, NULL); |
| 189 | if (ret == 0) { |
| 190 | delete wstring; |
| 191 | return NULL; |
| 192 | } |
| 193 | return string; |
| 194 | } |
| 195 | |
| 196 | int SU::FreeWChar(wchar_t * string) { |
| 197 | if (!string) |
nothing calls this directly
no outgoing calls
no test coverage detected