Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
I am running a script on Mac OS X that uses DBI to connect to FrontBase. The DBD:FB module seems to be returning everything in Unicode. Things mostly work except for when I am dealing with diacritics being passed to unicode unaware programs, at which point is morphed into √, is turned into √ and so on. I made a sub that did this:
sub sanitize { my $string = shift; $string =~ s/[]/a/; $string =~ s/[]/A/; $string =~ s//c/i; $string =~ s/[]/e/; $string =~ s/[]/E/; $string =~ s/[]/i/; $string =~ s/[]/I/; $string =~ s//n/; $string =~ s//N/; $string =~ s/[]/o/; $string =~ s/[]/u/; $string =~ s/[]/U/; return($string); }
but it does not work. None of the characters are converted, though if I use the sub on non-unicode text it works fine. I am sure the sub could be simplified, but right now I am just trying to get it to work at all.
I tried 'use UTF-8' thinking it might be needed, but then it gives this error "Malformed UTF-8 character at line xx" for each line of the regex, and again it does work on non-unicode, but does not work on unicode encoded text.

For now I know where the particular pieces of data that are problems are and I just match them with .*, and fix things, but I really want to have a more generic way of fixing this. I didn't see anything in the perlunicode perldoc that seemed to help other than "WARNING: The implementation of Unicode support in Perl is incomplete," which makes me think maybe it either imperfect Unicode support or Mac OS X flakiness, and not just me missing something. But the docs do say

"The existing regular expression compiler does not pro- duce polymorphic opcodes. This means that the deter- mination on whether to match Unicode characters is made when the pattern is compiled, based on whether the pattern contains Unicode characters, and not when the matching happens at run time."

I do not know how to interpret that and I would be very interested to hear what it means in terms of what I am trying to do. Also I wanted to ask the many knowledgeable folks here if anyone knew of a way to strip out diacritics in unicode, strip them in general (since my sub seems like it must be a re-invention but I could not find anything like it) or if perhaps I was missing something somewhere else that was relevant to my problem of flattening out diacritics.

In reply to questions about character encoding by moof1138

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (2)
    As of 2018-03-17 11:11 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (223 votes). Check out past polls.