Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Lost in encoding in Twig

by Krambambuli (Curate)
on Jan 09, 2015 at 16:46 UTC ( #1112778=note: print w/replies, xml ) Need Help??

in reply to Lost in encoding in Twig

Try this:
#!/usr/bin/perl use strict; use XML::Twig; use Encode qw( decode ); my $twig=XML::Twig->new(pretty_print => 'indented'); $twig->parse( '<?xml version="1.0" encoding="UTF-8"?><myxml/>'); my $root= $twig->root; $root->set_att( 'fille' => decode('UTF-8', 'clémence') ); open(PF, ">", "out.xml") or die "can't open file $!\n"; $twig->print(\*PF);


Replies are listed 'Best First'.
Re^2: Lost in encoding in Twig
by pcouderc (Monk) on Jan 10, 2015 at 07:13 UTC
    Thank you all for your help.
    My conclusions are:
    - utf8 is not so generalized that I did hope, certainly for 2 reasons, the weight of the past and all lines of code soon written. And certainly too because it is more a problem for non speaking english people.
    - there is not default utf8 at global perl level (and it could be dangerous)
    - an excellent default at scope level, and then at script level is:
    use utf8::all

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2022-10-01 10:28 GMT
Find Nodes?
    Voting Booth?
    I prefer my indexes to start at:

    Results (126 votes). Check out past polls.