Difference between revisions of "UTF8 Perl"
From Teknologisk videncenter
m (→Encoding æ ø å Æ Ø Å) |
|||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | = Using UTF8 in the source= | ||
+ | <source lang="perl"> | ||
+ | #!/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; | ||
+ | </source> | ||
= Encoding æ ø å Æ Ø Å = | = Encoding æ ø å Æ Ø Å = | ||
<source lang="perl"> | <source lang="perl"> | ||
Line 11: | Line 28: | ||
); | ); | ||
</source> | </source> | ||
− | [[category:Programming]][[Category:Perl]] | + | [[category:Programming]][[Category:Perl]][[Category:Character set]] |
Latest revision as of 04:18, 18 June 2012
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 Å
);