Difference between revisions of "UTF8 Perl"

From Teknologisk videncenter
Jump to: navigation, search
m (New page: = Encoding æ ø å Æ Ø Å = <source lang="perl"> my $str = "\n"; my @danishUTF = ( "\303\246", # Danish UTF æ "\303\270", # Danish UTF ø "\303\245", # Danish UTF å "\303\206"...)
 
m (Encoding æ ø å Æ Ø Å)
 
(3 intermediate revisions 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: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 Å
);