Hello everyone, this is my first post here and it's blowing my mind for about a month.

I'm making an application with Perl/CGI who receives a file with a text, splits this text into words and compare them with a database. Those texts are in Portuguese and are part of a research in Linguistics, so the use of utf8 is essential.

I'm using the module utf8::all and he's wonderful... until nearly the byte 4096 of the text. I'm highlighting this cause I think that couldn't be a coincidence that the problem occurs exactly around 4kb. From this point to the end of the file, the perl becomes just incapable to recognize any accented letter and start to do some weird things like split the word on the accented letter like that: word (A)á(B) became words (A) and (B).

That's the part of the code that I think may be interesting. The whole code have almost 400 lines.

use CGI; use utf8::all; my $c = new CGI; $c->import_names('P'); my $fh = $P::script; undef $/; my $text = <fh>; close $fh;

Any help would be great. This problem is disabling the whole research.

Thanks,

Gustavo Vieira.


In reply to Problem with utf8 after nearly 4096 bytes by gvieira

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.