| 1263 | |
| 1264 | |
| 1265 | ResultType Var::AssignStringToCodePage(LPCWSTR aBuf, int aLength, UINT aCodePage, DWORD aFlags, char aDefChar) |
| 1266 | { |
| 1267 | char *pDefChar; |
| 1268 | if (aCodePage == CP_UTF8 || aCodePage == CP_UTF7) { |
| 1269 | pDefChar = NULL; |
| 1270 | aFlags = 0; |
| 1271 | } |
| 1272 | else |
| 1273 | pDefChar = &aDefChar; |
| 1274 | int iLen = WideCharToMultiByte(aCodePage, aFlags, aBuf, aLength, NULL, 0, pDefChar, NULL); |
| 1275 | if (iLen > 0) { |
| 1276 | if (!SetCapacity(iLen, true)) |
| 1277 | return FAIL; |
| 1278 | LPSTR aContents = (LPSTR) Contents(TRUE); |
| 1279 | iLen = WideCharToMultiByte(aCodePage, aFlags, aBuf, aLength, aContents, iLen, pDefChar, NULL); |
| 1280 | aContents[iLen] = 0; |
| 1281 | if (!iLen) |
| 1282 | return FAIL; |
| 1283 | #ifndef UNICODE |
| 1284 | SetCharLength(aContents[iLen - 1] ? iLen : iLen - 1); |
| 1285 | #endif |
| 1286 | } |
| 1287 | else |
| 1288 | Assign(); |
| 1289 | return OK; |
| 1290 | } |
| 1291 | |
| 1292 | |
| 1293 |
nothing calls this directly
no test coverage detected