diff --git a/kaitai/kaitaistream.cpp b/kaitai/kaitaistream.cpp index 073a002..d1a7a5a 100644 --- a/kaitai/kaitaistream.cpp +++ b/kaitai/kaitaistream.cpp @@ -874,6 +874,14 @@ std::string kaitai::kstream::bytes_to_str(const std::string src, const char *src int kaitai::kstream::encoding_to_win_codepage(const char *src_enc) { std::string enc(src_enc); + + // See https://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers + // + // This method should handle at least all canonical encoding names listed in + // , + // preferably in the same order so that both sets of encodings can be easily compared. + if (enc == "ASCII") + return 20127; if (enc == "UTF-8") return CP_UTF8; if (enc == "UTF-16BE") @@ -966,8 +974,6 @@ int kaitai::kstream::encoding_to_win_codepage(const char *src_enc) { return 936; if (enc == "Big5") return 950; - if (enc == "ASCII") - return 20127; if (enc == "EUC-JP") return 20932; if (enc == "EUC-KR")