Modern Perls (the more modern the better) have mostly native Unicode support. Be sure to use feature qw/unicode_strings/;, and you may need to binmode FH, ':utf8'; your input and output filehandles (STDOUT, for example) so as not to have "wide character" warnings and problems. That said, chr and ord should just work as you wish, even with Unicode.

For more elaborate dealings, you may need one of the Encode modules, or Unicode::Collate, Unicode::UCD, Unicode::Normalize, or other modules.

There is a lot of information out there in Perl's documentation. perlunicode, perluniintro, perlunifaq, perlunitut to name a few. I'm sure that Programming Perl (4th Edition) (due to market in December) will shed additional light on the topic, especially since tchrist is listed as one of the authors. He seems to be waving the Perl Unicode flag a lot these days, so I imagine he will have a lot to contribute on the subject when the book is released. The book Modern Perl deals with Unicode to some degree, and there's a section on it in the Perl Cookbook as well, although the Cookbook was written before Perl really passed puberty with respect to Unicode.

Be glad you're dealing with Perl. Few languages have such a degree of native Unicode support as modern versions of Perl. C++, for example, requires the 3rd party ICU library (or something similar) just to get part of the functionality that ships with Perl 5.14.


Dave


In reply to Re: How to get the Unicode of a character in perl? by davido
in thread How to get the Unicode of a character in perl? by mattdeans

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.