Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: UTF8 issues again

by graff (Chancellor)
on Sep 13, 2011 at 09:49 UTC ( [id://925661]=note: print w/replies, xml ) Need Help??


in reply to UTF8 issues again

use Encode; # ... assign goofy string value to $test ... $test =~ s/%([0-9A-F]{2})/chr(hex($1))/eg; # convert hex digits to oct +ets $test = decode( "utf8", $test ); # convert octets to unicode characte +rs
The "decode" call (provided the Encode module) might not be necessary, depending on what you need to do with the string value. If you're just going to print it to a "raw" file handle, just print it with no further ado. But to use it as utf8 text (or print to a file handle that has been set to use utf8 mode) you need to "decode" it first.

UPDATE: Of course, ikegami's approach is the better way to go.

Replies are listed 'Best First'.
Re^2: UTF8 issues again
by ultranerds (Hermit) on Sep 13, 2011 at 11:07 UTC
    Thanks everyone - was me being stupid and not defining utf8 to STDOUT! Works a charm now :)

    Cheers

    Andy

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (8)
As of 2024-04-19 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found