Frank-Rene Schäfer Frank-Rene Schäfer - 1 month ago 8
C Question

Issue with ICONV writing BOM if output is platform endian

When choosing UTF-32, for platform dependent endian, libiconv
converts correctly but prefixes a 0xfeff BOM to the output
stream. This causes some trouble.

When choosing UCS-4, no BOM is written but on my system it
converts to 'big endian' which happens to be not the
endianness of my system.

Are there any suggestions how to convert to UTF-32/UCS-4
with the platform-dependent endianess without having the
remove the BOM manually?

Answer

If you don't specify a byte order, the default is always big endian. To use the byte order of the current platform, use the special UCS-4-INTERNAL (or UCS-2-INTERNAL) encoding.

Comments