in reply to Mixed ISO-8859/UTF-8 conversion

Please use Perl's built in support for encodings. Read perlunitut to find out all about Perl's Unicode strings.

sub decode_utf8_latin1 { my ($encoded) = @_; my $decoded; while (length $encoded) { $decoded .= decode("UTF-8", $encoded, Encode::FB_QUIET); $decoded .= substr($encoded, 0, 1, "") if length $encoded; } return $decoded; }

If CHECK = coderef worked, you could just write decode("UTF-8", $encoded, sub { chr shift }, but alas, it doesn't work.

Juerd # { site => 'juerd.nl', do_not_use => 'spamtrap', perl6_server => 'feather' }

Replies are listed 'Best First'.
Re^2: Mixed ISO-8859/UTF-8 conversion
by olli (Initiate) on Oct 04, 2007 at 11:39 UTC
    Wow. It's a bit hard to understand. I didn't expect Encode::FB_QUIET to change $encoded. But that's a better way, thanks a lot.

      I didn't expect Encode::FB_QUIET to change $encoded.

      All I can say is RTFM ;-)