UTF8 Perl

From Teknologisk videncenter
Revision as of 04:18, 18 June 2012 by Heth (talk | contribs) (Encoding æ ø å Æ Ø Å)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Using UTF8 in the source

#!/usr/bin/perl
use utf8;
binmode STDIN, ':encoding(UTF-8)';
binmode STDOUT, ':encoding(UTF-8)';
print "æøåÆØÅ\n";
open F, ('> ./utf8.out');
binmode F, ':encoding(UTF-8)';
binmode F, ':encoding(UTF-8)';
print F "æøåÆØÅ\n";
my $øl = 'Gælder årstøl';
if ( $øl =~ /Gælder (.*)/) { #Using UTF 
    print $1;
}
close F;

Encoding æ ø å Æ Ø Å

my $str = "\n";
my @danishUTF = (
  "\303\246", # Danish UTF æ
  "\303\270", # Danish UTF ø
  "\303\245", # Danish UTF å
  "\303\206", # Danish UTF Æ
  "\303\230", # Danish UTF Ø
  "\303\205", # Danish UTF Å
);