MCPcopy Create free account
hub / github.com/ashkulz/NppFTP / WCharToChar

Method WCharToChar

src/StringUtils.cpp:170–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170char* 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
196int SU::FreeWChar(wchar_t * string) {
197 if (!string)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected