Skip to content

Commit

Permalink
bytes_to_str() Win32: add sources we should be consistent with
Browse files Browse the repository at this point in the history
  • Loading branch information
generalmimon committed Sep 23, 2024
1 parent 684925f commit a148ee2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kaitai/kaitaistream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
// <https://github.com/kaitai-io/kaitai_struct_compiler/blob/5832a81a48e10c3c207748486e09bd58b9aa4000/shared/src/main/scala/io/kaitai/struct/EncodingList.scala>,
// 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")
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit a148ee2

Please sign in to comment.