Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Answer: How do I convert a string to Unicode and back (v5.005_03)?

by Zombie negative64 (Initiate)
on Aug 07, 2001 at 19:45 UTC ( #102815=categorized answer: print w/replies, xml ) Need Help??

Q&A > strings > How do I convert a string to Unicode and back (v5.005_03)? - Answer contributed by Zombie negative64

I should warn you that while this code may work for ascii, it most definitely will not work for other character sets and/or encodings.

You can use the Unicode::Map module like this:

   perl -MUnicode::Map -e'print Unicode::Map->new(shift)->to8(<>)' 
There is also to16() if you need utf16.

Note that not all mappings are round-trip, i.e. you won't necessarily get back what you put in if you try to "undo" the conversion.

For lots and lots of information on dealing with complex character set and encoding issues, see Ken Lunde's excellent book CJKV Information Processing from O'Reilly.

Or to skip the reading, you can just go to the examples and look at the perl directory.

  • Comment on Answer: How do I convert a string to Unicode and back (v5.005_03)?
Log In?

What's my password?
Create A New User
[atcroft]: Lady_Aleena: By the way, I did look up another module (Tk), to see how it referred to other modules, and it used the L<module_name> POD linking, whereas the one I ran into today had hard-coded l<text|url> links.
[atcroft]: Sorry... L>text|url< links.
[atcroft]: Grrr.... L<text|url> links. .oO(Come on, brain, fingers, get it right this time.)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-05-27 05:15 GMT
Find Nodes?
    Voting Booth?