Files
serenity/Userland/Libraries/LibTextCodec
Nico Weber 7154218094 LibTextCodec: Add UTF16BEEncoder, UTF16LEEncoder
Makes these work (and produce the same output as macOS system `iconv`):

    echo 😀 | Build/lagom/bin/iconv -f utf-8 -t utf-16be | xxd
    echo 😀 | Build/lagom/bin/iconv -f utf-8 -t utf-16le | xxd

This probably doesn't affect LibWeb, since over there TextEncoders
are usually created with the result of TextCodec::get_output_encoding(),
which maps utf-16be and utf-16le to utf-8.

(Originally I thought I'd use this to make the
ExtensionType::MultiByteCodedComment implementation in JBIG2Writer.cpp
look more similar to the ExtensionType::SingleByteCodedComment one,
but the TextCodec::Encoder interface doesn't make it easily possible
to reject surrogate pairs, so I'm not doing that part. Maybe we'll
add an ucs-2be one day.)
2025-10-24 21:28:58 -04:00
..