Hi. First of all, I am running 5.8.8 on solaris. Also, I do not have the option of downloading modules from cpan (company policy).

I am helping someone who receives about 100Mb of data from another organization. He needs me to identify bad characters in the data.

My initial thought was to use the "ord" function and report the line number and column number of characters < 32 ascii or > 126 ascii. After doing some reading, I am wondering if that was the wrong approach.

It is unknown what encoding this is supposed to be. Some files may be sent in the wrong encoding.

Bottom line: will my approach of < 32 ascii or > 126 ascii work despite the actual encoding sent?

The null characters are in a separate report

while( $line =~ /\G(.)/g ) { my $this_char = $1; ++$char_in_line; my $ascii = ord $this_char; if( ( $ascii < 32 || $ascii > 126 ) && $ascii != 0 ) { ++$total_bad_chars{$ascii}; printf "filename: %s -- line_n: %d -- char_in_line: %4d -- as +cii: %4d\n", $filename, $line_n, $char_in_line, $ascii; } }

I am continuing to read, but I am fairly well confused. Maybe this new concept (for me) will begin to gel.

Thanks, Jim


In reply to unknown encoding by jimw54321

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.