Files
serenity/Userland/Libraries/LibTextCodec/Encoder.cpp
Nico Weber 286872c135 LibTextCodec: Add Latin1Encoder for encoder_for_exact_name("iso-8859-1")
Latin1Encoder matches Latin1Decoder, and matches the first 256
codepoints of Unicode.

Note that on the web, iso-8859-1 actually gets you windows-1252:
https://encoding.spec.whatwg.org/#note-latin1-ascii

This is implemented in get_standardized_encoding(), which encoder_for()
calls. One has to call encoder_for_exact_name("iso-8859-1") to get this
new encoder.

That means both browser and iconv won't see this encoder.

(Maybe iconv should try calling encoder_for_exact_name() first, and
encoder_for() only if that doesn't return anything?)

This is a bit weird and subtle, but it matches the decoder, is
compatible with the web, and still allows code that does want actual
iso-8859-1 to get it.

See also #24594, especially the fourth commit, and #25119, which
picked up this design for the encoders as well.
2025-10-24 21:28:58 -04:00

25 KiB