Hi there. Im facing a encoding issue that i dont know how fix it. Im reading records from a file and reading a file. try to match the think i read from the file, to one of the records i had readed from the file, if found, it use a code assigned an write to the file. When i read the data to be loaded in a hash with his code and get ready to be compared against the data extracted from the files, ir read the data right. I use a subrroutine to convert every quote or accent to the same letter without this special character.
sub translator { + $vNombre = $_[0]; $vNombre = lc $vNombre; $vNombre =~ tr/áàèéìíòóùú/aaeeiioouu/; $vNombre =~ tr/ÀÁÈÉÌÍÒÓÙÚ/AAEEIIOOUU/; $vNombre =~ tr/"'/||/d; return $vNombre; }
But, when i read the xml has a plain text (using a While <FILEHANDLE>), i sent the data to the subrroutine to format it, using that condition:
if ($vl_read =~ /<hwAssetUserField3 type="attrib">(.+?)<\/hwAssetUserF +ield3>/){ $vNombre = $1; $vNombre = &translator($vNombre);
But when i print the data, it seems it takes the accent, quotes and so on, not as a ó or á letter, or a "" or '', its use weird characters.
&apos;galicia vii&apos; it should be "galicia vii"
or at last, it should detect " in the tr and change it to another character of (see the /d option), eliminate, but no. Also, if it reads a accent vowel, it reads, for example:
centro de apoyo inform&#9500;ítico when it should read centro de apoyo + informatico.
Im using a spanish computer, but it seems perl its reading in a wrong way from the xml file but not from a txt file. Any idea???? Thanks!

In reply to Problem with quotes, speciao characters and so on, reading a xml file by Sombrerero_loco

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.