in reply to need help in printing German umlauts

A similar issue was discussed recently in unicode problem with Email::Valid; McA has good information and tips in Re: unicode problem with Email::Valid. The short version: use Encode;, and then decode your data as MIME-Header (and encode the same way it when you'd like to go the other way).

#!/usr/bin/perl use feature qw/say/; use warnings; use strict; use Encode; say decode('MIME-Header', "=?iso-8859-1?Q?=C3=BC =C3=B6 =C3=A4?=");

Output:

$ perl test.pl ü ö ä $

Replies are listed 'Best First'.
Re^2: need help in printing German umlauts
by opensourcer (Monk) on Jul 08, 2014 at 17:52 UTC
    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

      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