danj35 has asked for the wisdom of the Perl Monks concerning the following question:

Hi

I'm having trouble converting some strings to unicode. I think the original encoding was MacRoman. Incidentally the strings have ended up looking like this:

Walther-Straub-Institut f\x{fc}r Pharmakologie und Toxikologie, Ludwig Maximillians-Universit\x{e4}t M\x{fc}nchen, Germany

Does anyone know how to convert these to unicode or another format that makes the text recognisable?

Thanks,

Dan

Replies are listed 'Best First'.
Re: MacRoman Encoding Problem
by Anonymous Monk on Aug 31, 2011 at 13:04 UTC
      Better supply a code sample:
      use Encode qw(); use Encode::Escape qw(); decode('Latin1', decode('unicode-escape', 'Walther-Straub-Institut + f\x{fc}r Pharmakologie und Toxikologie, Ludwig Maximillians-Universi +t\x{e4}t M\x{fc}nchen, Germany')) # returns a Perl string

      Thanks. Although perhaps I should have been more specific. I would like the string converted into this format:

      Walther-Straub-Institut für Pharmakologie und Toxikologie, Ludwig Maximillians-Universität München, Germany.

        #!/bin/env perl use strict; use warnings; binmode STDOUT, ':encoding(utf-8)'; print "Walther-Straub-Institut f\x{fc}r Pharmakologie und Toxikologie, + Ludwig Maximillians-Universit\x{e4}t M\x{fc}nchen, Germany\n";