- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

Malformed UTF-8 character (%s)

(S utf8) (F) Perl detected a string that didn't comply with UTF-8 encoding rules, even though it had the UTF8 flag on.

One possible cause is that you set the UTF8 flag yourself for data that you thought to be in UTF-8 but it wasn't (it was for example legacy 8-bit data). To guard against this, you can use Encode::decode_utf8.

If you use the :encoding(UTF-8) PerlIO layer for input, invalid byte sequences are handled gracefully, but if you use :utf8, the flag is set without validating the data, possibly resulting in this error message.

See also "Handling Malformed Data" (Encode) in the Perl Unicode and Locales Manual.

ISBN 9781906966027Perl Language Reference ManualSee the print edition