| 1307 | } |
| 1308 | |
| 1309 | static UINT ConvertFileEncoding(LPTSTR aBuf) |
| 1310 | // Returns the encoding with possible CP_AHKNOBOM flag, or (UINT)-1 if invalid. |
| 1311 | { |
| 1312 | if (!aBuf || !*aBuf) |
| 1313 | // Active codepage, equivalent to specifying CP0. |
| 1314 | return CP_ACP; |
| 1315 | if (!_tcsicmp(aBuf, _T("UTF-8"))) return CP_UTF8; |
| 1316 | if (!_tcsicmp(aBuf, _T("UTF-8-RAW"))) return CP_UTF8 | CP_AHKNOBOM; |
| 1317 | if (!_tcsicmp(aBuf, _T("UTF-16"))) return 1200; |
| 1318 | if (!_tcsicmp(aBuf, _T("UTF-16-RAW"))) return 1200 | CP_AHKNOBOM; |
| 1319 | if (!_tcsnicmp(aBuf, _T("CP"), 2)) |
| 1320 | aBuf += 2; |
| 1321 | if (IsNumeric(aBuf, false, false)) |
| 1322 | { |
| 1323 | // CPnnn |
| 1324 | UINT cp = ATOU(aBuf); |
| 1325 | // Catch invalid or (not installed) code pages early rather than |
| 1326 | // failing conversion later on. |
| 1327 | if (IsValidFileCodePage(cp)) |
| 1328 | return cp; |
| 1329 | } |
| 1330 | return -1; |
| 1331 | } |
| 1332 | |
| 1333 | static UINT ConvertFileEncoding(ExprTokenType &aToken); |
| 1334 |
nothing calls this directly
no test coverage detected