Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by kcott (Abbot)
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


Comment on Re^3: Why won't Perl convert (Latin1 | ISO-8859-1) to (UTF-8 | utf8)?
Select or Download Code
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!
    Thanks!
    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.

    --chris

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037528]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2015-07-05 16:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls