Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re^3: Why won't Perl convert (Latin1 | ISO-8859-1) to (UTF-8 | utf8)?

by kcott (Chancellor)
on Jun 06, 2013 at 23:35 UTC ( #1037528=note: print w/replies, xml ) Need Help??

in reply to Re^2: Why won't Perl convert (Latin1 | ISO-8859-1) to (UTF-8 | utf8)?
in thread Why won't Perl convert (Latin1 | ISO-8859-1) to (UTF-8 | utf8)?

Thanks for your complimentary remarks — they are appreciated.

piconv does use Encode. It's also relatively short: if you ignore the option handling, POD, etc., you're left with probably less than 100 lines of code. So, if you wanted to use that as a starting point to roll your own version, I don't imagine it would be an overwhelmingly difficult task. However, having said that, if this is just a one-off exercise, perhaps something along these lines would suffice:

$ for i in latin/*.html; do > piconv -f ISO-8859-1 -t utf8 $i | \ > perl -pe 's/((?>charset|encoding)=)iso-8859-1/${1}utf-8/gi' - \ > > utf8/`basename $i` > done

-- Ken

Replies are listed 'Best First'.
Re^4: Why won't Perl convert (Latin1 | ISO-8859-1) to (UTF-8 | utf8)?
by taint (Chaplain) on Jun 07, 2013 at 21:04 UTC
    Greetings kcott, and thanks for your reply.

    Indeed. That does do the trick!
    I sure wish I was as well versed in Perl as you are. But I'm afraid I've got a ways to go yet. :(

    As always, very grateful for all your time, and consideration.


    #!/usr/bin/perl -Tw
    use perl::always;
    my $perl_version = "5.12.4";
    print $perl_version;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037528]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2018-06-19 16:40 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (114 votes). Check out past polls.