I'm using Josh Carter's IPTCInfo package on cpan that reads the IPTC header from an image (e.g., jpg) and fills in fields such as "author", "location", etc. The problem is, some data may be corrupted, or perhaps unintelligible because it's written in a different language. Is there a way to know which?

At first, it seemed simple to just check for normal ascii, but then it occurs to me that I want to accept certain accented characters, like the é in café, and so on...

Before I go off writing some routine that checks for santiy in a string to see if it really is english text instead of arbitrary gobblygook, I figured maybe someone had such a thing. Even if I only look at the first N characters in a string, that'd be fine.

Again, the brute force intuitive step would be to just do something like

$string =~ /([\s\w]){25})/

but this seems like a hornet's nest of little gotchas where people have learned it ain't that simple.


In reply to string? Or binary garbage? by argv

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.