in reply to Re: need help in printing German umlauts
in thread need help in printing German umlauts

I tried the above example provided and it works perfectly fine.
But when I tried the below it fails.
#!/usr/bin/perl use feature qw/say/; use warnings; use strict; use Encode; #assuming that my message is stored in some variable called $str my $str="Wir freuen uns, dass Sie den 1&1 E-Mail-Service f=C3=BCr Ihre +=20"; print decode('MIME-Header', "Wir freuen uns, dass Sie den 1&1 E-Mail-S +ervice f=C3=BCr Ihre=20"); print "\n"; print decode('MIME-Header', "=?iso-8859-1?Q?".$str);
Thanks
Arun

Replies are listed 'Best First'.
Re^3: need help in printing German umlauts
by AppleFritter (Vicar) on Jul 08, 2014 at 18:16 UTC

    Don't forget the trailing ?=:

    #!/usr/bin/perl use feature qw/say/; use warnings; use strict; use Encode; my $str = "Wir freuen uns, dass Sie den 1&1 E-Mail-Service f=C3=BCr Ih +re=20"; say decode('MIME-Header', "=?iso-8859-1?Q?" . $str . "?=");

    Output:

    $ perl 1092761.pl Wir freuen uns, dass Sie den 1&1 E-Mail-Service für Ihre $
      Thanks a lot that resolved many issues, the encode doesn't work for Ü and ß
      instead prints as ~_ for ß and ~\ as for Ü
      Thanks again for the help

        Those work for me:

        #!/usr/bin/perl use feature qw/say/; use warnings; use strict; use Encode; my $str = "=C3=9C =C3=9F"; say decode('MIME-Header', "=?iso-8859-1?Q?" . $str . "?=");

        Output:

        $ perl 1092761.pl Ü ß $

        Are you sure your the encoded data's correct? The string should contain the UTF-8 encoding of the character, in essence (for instance, "ß" is C3 9F in UTF-8, so it's encoded as =C3=9F).