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

Hi In Sweden we don't have any swedish forum.I have looked the man page but don't understand them where they talk about unicoding.Can someone please help to make this script writing the apropriate letters?
#!/usr/bin/perl -w use encoding "utf8"; use strict; my @a=("a"..."ö"); for (@a ) { print $_\n; }

Replies are listed 'Best First'.
Re: How to convert this to swedish characters?
by varian (Chaplain) on Feb 08, 2007 at 10:12 UTC
      Also note that the '..' operator does not handle the special character as one might expect.
      Try the below alternative and you will find that it shows just fine:
      #!/usr/bin/perl -w use encoding "utf8"; use strict; my $start=ord("a"); my $finish=ord("ö"); # use ord value to properly fill the list my @a=($start..$finish); for (@a ) { print chr($_)," $_\n"; } # show that list construct works fine without '..' @a=("a","ö"); print "$_\n" foreach (@a);
        Thank You for your fast reply, but it didn't work. Error:
        Malformed UTF-8 character (1 byte, need 4, after start byte 0xf6) at . +/tryitut line 7. Tried also with use encoding "iso-8859-1"; It made my question more clear to me That worked, but I don't want anything else than the swedish alphabet +to be printed on the screen not the number represent a letter or anyt +hing different at all. How can I do that? I have perl version: perl -v This is perl, v5.8.8 built for i486-linux