Permalink
Browse files

add :enc/:encoding support to &open

  • Loading branch information...
1 parent 5e3dfe9 commit 88a9d69d6c3221cf16fb7134eef77a076b35888f @moritz moritz committed Jun 27, 2012
Showing with 6 additions and 4 deletions.
  1. +1 −0 docs/ChangeLog
  2. +5 −4 src/core/IO.pm
View
@@ -2,6 +2,7 @@ New in 2012.07
+ Deprecated SAFE.setting in favor of RESTRICTED.setting
+ Ranges can now interpolate in argument lists
+ The built-in meta-objects (such as Metamodel::ClassHOW) now inherit from Any
++ &open now supports :enc/:encoding
New in 2012.06
+ Rakudo is now compiled with the same regex engine as user-space regexes use
View
@@ -34,7 +34,8 @@ class IO {
has $.path;
proto method open(|$) { * }
- multi method open($path, :$r, :$w, :$a, :$bin, :$chomp = Bool::True) {
+ multi method open($path, :$r, :$w, :$a, :$bin, :$chomp = Bool::True,
+ :enc(:$encoding) = 'utf8') {
my $mode = $w ?? 'w' !! ($a ?? 'wa' !! 'r');
# TODO: catch error, and fail()
nqp::bindattr(self, IO, '$!PIO',
@@ -44,7 +45,7 @@ class IO {
);
$!path = $path;
$!chomp = $chomp;
- $!PIO.encoding($bin ?? 'binary' !! 'utf8');
+ $!PIO.encoding($bin ?? 'binary' !! PARROT_ENCODING($encoding));
self;
}
@@ -260,8 +261,8 @@ sub rmdir($path) {
}
proto sub open(|$) { * }
-multi sub open($path, :$r, :$w, :$a, :$bin, :$chomp = Bool::True) {
- IO.new.open($path, :$r, :$w, :$a, :$bin, :$chomp);
+multi sub open($path, :$r, :$w, :$a, :$bin, :$chomp = Bool::True, :enc(:$encoding) = 'utf8') {
+ IO.new.open($path, :$r, :$w, :$a, :$bin, :$chomp, :$encoding);
}
proto sub lines(|$) { * }

0 comments on commit 88a9d69

Please sign in to comment.