Skip to content

Commit

Permalink
bytes_to_str() Win32: explicitly list UTF-32* as unsupported
Browse files Browse the repository at this point in the history
I think it is better to admit that they're not implemented yet than to
pretend they don't exist. Explicitly returning `KAITAI_CP_UNSUPPORTED`
serves like a "TODO" comment, while omitting them pretends everything is
fine. They are also in KSC's
[`EncodingList`](https://github.com/kaitai-io/kaitai_struct_compiler/blob/5832a81a48e10c3c207748486e09bd58b9aa4000/shared/src/main/scala/io/kaitai/struct/EncodingList.scala#L21-L22),
so the fact that the `KS_STR_ENCODING_WIN32API` mode doesn't support
them is a limitation and we should be able to see it directly in the
code.
  • Loading branch information
generalmimon committed Sep 23, 2024
1 parent 6868e3b commit 684925f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kaitai/kaitaistream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,16 @@ int kaitai::kstream::encoding_to_win_codepage(const char *src_enc) {
return KAITAI_CP_UTF16BE;
if (enc == "UTF-16LE")
return KAITAI_CP_UTF16LE;
if (enc == "UTF-32BE") {
// It has a code page number 12001 assigned to it, but it's "available only to
// managed applications", so we can't use it.
return KAITAI_CP_UNSUPPORTED;
}
if (enc == "UTF-32LE") {
// It has a code page number 12000 assigned to it, but it's "available only to
// managed applications", so we can't use it.
return KAITAI_CP_UNSUPPORTED;
}
if (enc == "ISO-8859-1")
return 28591;
if (enc == "ISO-8859-2")
Expand Down

0 comments on commit 684925f

Please sign in to comment.