in reply to Re^2: i18n/utf8 problem, 'utf8 "\xF8" does not map to Unicode'
in thread i18n/utf8 problem, 'utf8 "\xF8" does not map to Unicode'
If you have the raw bytestring, the easiest way to see if it's valid UTF-8 is to decode it to a unicode string. If that fails, it wasn't utf8 enough :)
orutf8::decode($string) or die "Input is not valid UTF-8";
If you leave out the "or die" clause, any invalid UTF-8 will just be seen as ISO-8859-1.utf8::decode(my $text = $binary) or die "Input is not valid UTF-8";
Update: changed the examples as per ikegami's sound response.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: i18n/utf8 problem, 'utf8 "\xF8" does not map to Unicode'
by ikegami (Patriarch) on Feb 25, 2008 at 17:40 UTC |