check files for 16 or 32 bit encoding the file must have a Byte Order Mark (BOM) NOTE: some string functions don't work with NULLs (e.g. length())
| 389 | // the file must have a Byte Order Mark (BOM) |
| 390 | // NOTE: some string functions don't work with NULLs (e.g. length()) |
| 391 | FileEncoding ASConsole::detectEncoding(const char* data, size_t dataSize) const |
| 392 | { |
| 393 | FileEncoding encoding = ENCODING_8BIT; |
| 394 | |
| 395 | if (dataSize >= 4 && memcmp(data, "\x00\x00\xFE\xFF", 4) == 0) |
| 396 | encoding = UTF_32BE; |
| 397 | else if (dataSize >= 4 && memcmp(data, "\xFF\xFE\x00\x00", 4) == 0) |
| 398 | encoding = UTF_32LE; |
| 399 | else if (dataSize >= 2 && memcmp(data, "\xFE\xFF", 2) == 0) |
| 400 | encoding = UTF_16BE; |
| 401 | else if (dataSize >= 2 && memcmp(data, "\xFF\xFE", 2) == 0) |
| 402 | encoding = UTF_16LE; |
| 403 | |
| 404 | return encoding; |
| 405 | } |
| 406 | |
| 407 | // error exit without a message |
| 408 | void ASConsole::error() const |
nothing calls this directly
no outgoing calls
no test coverage detected