Created
May 28, 2010 10:24
-
-
Save masak/417012 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
multi method decode($encoding = 'UTF-8') { | |
my @contents = @.contents; | |
my $str = ~Q:PIR { | |
$P0 = find_lex '@contents' | |
.local pmc iterator | |
iterator = iter $P0 | |
.local pmc sb | |
sb = new 'StringBuilder' | |
sb = unicode:"" | |
loop: | |
unless iterator goto done | |
$P1 = shift iterator | |
$I1 = $P1 | |
$S1 = chr $I1 | |
sb .= $S1 | |
goto loop | |
done: | |
%r = sb | |
}; | |
return $str; | |
} | |
1..10 | |
ok 1 - $str.encode returns a Buf | |
ok 2 - encoding to ASCII | |
ok 3 - right length of Buf | |
ok 4 - # SKIP Parrot breaks on this | |
ok 5 - right length of Buf | |
ok 6 - # SKIP Parrot breaks when fed non-ASCII | |
perl6(75961) malloc: *** error for object 0x106c355c8: pointer being reallocated was not allocated | |
*** set a breakpoint in malloc_error_break to debug | |
Abort trap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment