I am not familiar with this stuff either, but I think you need to know a little more about your data: what is the encoding of this text? Unicode or Shift-JIS (that's a Japanese encoding, it can also encode Roman characters)? Look for the encoding declaration in your HTML document, it should look like <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=x-sjis"> for shift-JIS.

If it is shift-JIS you can use the shift-JIS table to figure out how to separate Roman characters (130,96 to 130,154) from the rest. You have to decide what to do with punctuation, spaces, $ and the likes, which can belong to either kind of text though.

An other way is to convert to Unicode using Text::Iconv, and then use Unicode::Charname to get the name of each character (if it starts with LATIN it's a latin character!).

In any case, please let us know how you solve that problem.

By the way, I think you need Perl 5.6 to do Unicode processing, so be ready to update if you haven't already.

Mirod, ready and fully functional (see picture)


In reply to Re: Regular Expression 1 byte vs 2 byte characters by mirod
in thread Regular Expression 1 byte vs 2 byte characters by feloniousMonk

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.