Skip to content

Commit

Permalink
code move to fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fayland committed Nov 3, 2015
1 parent b40e799 commit ff5053a
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions lib/Encode.pm6
Expand Up @@ -12,6 +12,30 @@ my class X::Encode::Unknown is Exception {
}
}

sub latin2(Buf $buf) {
$buf.list.map({ %Encode::Latin2::map{$_} // $_ })>>.chr.join;
}

sub latin1(Buf $buf) {
$buf.decode('iso-8859-1');
}

sub utf8(Buf $buf) {
$buf.decode('utf8');
}

sub ascii(Buf $buf) {
$buf.decode('ascii');
}

sub cp1251(Buf $buf) {
$buf.list.map({ %Encode::Windows1251::map{$_} // $_ })>>.chr.join;
}

sub cp1252(Buf $buf) {
$buf.list.map({ %Encode::Windows1252::map{$_} // $_ })>>.chr.join;
}

my %encodings =
'iso-8859-2' => &latin2,
'iso_8859-2' => &latin2,
Expand Down Expand Up @@ -45,30 +69,6 @@ our sub decode($encoding, Buf $buf) {
&(%encodings{$encoding})($buf);
}

sub latin2(Buf $buf) {
$buf.list.map({ %Encode::Latin2::map{$_} // $_ })>>.chr.join;
}

sub latin1(Buf $buf) {
$buf.decode('iso-8859-1');
}

sub utf8(Buf $buf) {
$buf.decode('utf8');
}

sub ascii(Buf $buf) {
$buf.decode('ascii');
}

sub cp1251(Buf $buf) {
$buf.list.map({ %Encode::Windows1251::map{$_} // $_ })>>.chr.join;
}

sub cp1252(Buf $buf) {
$buf.list.map({ %Encode::Windows1252::map{$_} // $_ })>>.chr.join;
}

=begin pod
=head1 NAME
Expand Down

0 comments on commit ff5053a

Please sign in to comment.