correct 'strange' utf-8 and convert it into latin

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tgirard
    New Member
    • Nov 2006
    • 2

    correct 'strange' utf-8 and convert it into latin

    Hello to all

    Before I pull all my hair out... I have a problem with a text string (actually read in from a cell-phone appointment sent to the computer) which has a 'strange' utf-8 encoding.

    Let me give an example:
    CHARSET=UTF-8:Aftenarr.=20m ed=20Fl.=20Th=C 3=B8gersen

    Now I need to convert this into latin.
    I tried to replace all the '=' into '\x'. doing this by regex I have to use \\x$1 as a substitute, but then the string is not recognized as utf8.
    If I set the string 'manuall' to:
    my $str = "Aftenarr.\x20m ed\x20Fl.\x20Th \xC3\xB8gersen" ;

    then it works. But of course that's not a solution, as I have to read in a lot of appointments.

    Can please somebody give me a hand?

    thanks a lot
    Thierry
  • GunnarH
    New Member
    • Nov 2006
    • 83

    #2
    Code:
    use MIME::QuotedPrint;
    use Encode;
    
    my $utf8 = decode_qp('Aftenarr.=20med=20Fl.=20Th=C3=B8gersen');
    print decode('utf8', $utf8);

    Comment

    • tgirard
      New Member
      • Nov 2006
      • 2

      #3
      this is 2 days I was 'fighting' with this problem!
      Thank you so very much!!

      regards
      Thierry

      Originally posted by GunnarH
      Code:
      use MIME::QuotedPrint;
      use Encode;
      
      my $utf8 = decode_qp('Aftenarr.=20med=20Fl.=20Th=C3=B8gersen');
      print decode('utf8', $utf8);

      Comment

      Working...