Skip to content

Commit 684925f

Browse files
committed
bytes_to_str() Win32: explicitly list UTF-32* as unsupported
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.
1 parent 6868e3b commit 684925f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

kaitai/kaitaistream.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,16 @@ int kaitai::kstream::encoding_to_win_codepage(const char *src_enc) {
880880
return KAITAI_CP_UTF16BE;
881881
if (enc == "UTF-16LE")
882882
return KAITAI_CP_UTF16LE;
883+
if (enc == "UTF-32BE") {
884+
// It has a code page number 12001 assigned to it, but it's "available only to
885+
// managed applications", so we can't use it.
886+
return KAITAI_CP_UNSUPPORTED;
887+
}
888+
if (enc == "UTF-32LE") {
889+
// It has a code page number 12000 assigned to it, but it's "available only to
890+
// managed applications", so we can't use it.
891+
return KAITAI_CP_UNSUPPORTED;
892+
}
883893
if (enc == "ISO-8859-1")
884894
return 28591;
885895
if (enc == "ISO-8859-2")

0 commit comments

Comments
 (0)