charsethero : convert mixed utf-8 and iso-latin content to utf-8
✓ Published0🌍 Public
PPhilippe Rivière
Last edited Jun 8, 2014
Created on Jun 8, 2014
This example demonstrates a command-line Perl script that converts mixed UTF-8 and ISO 8859-1 encoded text into a single UTF-8 stream. It reads from standard input, processes each line, and outputs the converted result. The core logic uses regular expressions to identify multi-byte UTF-8 sequences and single-byte Latin-1 characters, then applies the `encode_char_utf8` function to re-encode any non-UTF-8 bytes. The script also includes a `force_latin` function for reverse conversion, though the main pipeline calls `force_utf8`. The data source is standard input, making it a filter for text streams.
AI-generated description