/[scripts]/trunk/fix-utf8-iso88591-encoding.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/fix-utf8-iso88591-encoding.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 119 - (show annotations)
Fri Jul 31 12:32:52 2009 UTC (13 years, 6 months ago) by dpavlin
File MIME type: text/plain
File size: 386 byte(s)
fix encoding in files with mixed UTF-8 and ISO-8859-1 encoding

1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 # slightly modified from http://plasmasturm.org/log/416/
6
7 use Encode qw( decode FB_QUIET );
8
9 binmode STDIN, ':bytes';
10 binmode STDOUT, ':encoding(UTF-8)';
11
12 while ( <> ) {
13 while ( length ) {
14 my $out = '';
15 $out .= decode( "utf-8", $_, FB_QUIET );
16 $out .= decode( "iso-8859-1", substr( $_, 0, 1 ), FB_QUIET ) if length;
17 print $out;
18 }
19 }
20

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26