This is a clarified and restated question. I have a file in UTF-8 format and I want to find and tally all of the non-ascii characters in it. The very first steps are paralyzing me. With the patient help of Thelonius, John M. Dlugosz, and others, I have come this far:
while (<FILE>){
if(/[\xc0-\xfd]/)#found lead byte of a multibyte sequence
My data has a maximum character length of 3 bytes, but I might not have known that. How do I grab at the entire character, so I can put it into a hash tallying the number of times it appears? The camel says "regular expressions match characters instead of bytes". The man pages on pack() and unpack() say something clearly important that I am unable to comprehend at my stage. Can somebody either hint at the next step in my code, or direct me to documentation that would help? Thank you
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.