Skip to main content

encode_latin1

Function encode_latin1 

Source
pub fn encode_latin1(s: &str) -> Vec<u8> 
Expand description

Encode a UTF-8 string as Latin-1 (ISO 8859-1) bytes — the inverse of decode_latin1.

Each code point U+0000–U+00FF maps to a single byte; anything above is not representable in Latin-1 and is substituted with ?, matching Perl ExifTool’s default behaviour when writing a character the IPTC internal charset can’t hold (the alternative is declaring CodedCharacterSet = UTF8). Without this, a UTF-8 &str written straight to an IPTC-IIM dataset double-encodes: í (U+00ED → UTF-8 C3 AD) reads back as í under the default Latin-1 IPTC charset.