in reply to convert files to ansi (8859-1)
At least in your second example, you are not properly decoding your input.
eval { $sCodepoints = decode( "iso-8859-1", $sLine, Encode::FB_CROAK ) + }; if ( $@ ) { # input was not iso-8859-1 print "> No ISO-8859-1, maybe UTF8 ?\n"; $sCodepoints = $sLine; }
Here, $sCodepoints does not contain properly decoded UTF-8.
I would try a loop over the possible encodings:
for my $encoding_candidate (qw(iso-8859-1 UTF-8)) { eval { $sCodepoints = decode( $encoding_candidate, $sLine, Encode::FB_ +CROAK ) }; if ( $@ ) { # input was not $encoding_candidate print "> Not $encoding_candidate\n"; #$sCodepoints = $sLine; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: convert files to ansi (8859-1)
by Yaerox (Scribe) on Mar 29, 2017 at 08:15 UTC | |
by Corion (Patriarch) on Mar 29, 2017 at 08:17 UTC | |
by Yaerox (Scribe) on Mar 29, 2017 at 08:33 UTC | |
by Corion (Patriarch) on Mar 29, 2017 at 08:35 UTC | |
by Yaerox (Scribe) on Mar 29, 2017 at 08:39 UTC | |
|