reading binary stream?

2010-12-28 Thread Hiroki Horiuchi

Hello.

This program
--
#!/usr/bin/env perl6

use v6;

my $h = open '/dev/urandom', :r;
loop (;;) {
  $h.getc;
}
--
spits an error below.
--
Malformed UTF-8 string

  in 'IO::getc' at line 5457:CORE.setting
  in main program body at line 7:./getc.p6
--
How can I fix the problem?

Thank you.
--
Hiroki Horiuchi




Re: reading binary stream?

2010-12-28 Thread Moritz Lenz
Hi,

On 12/28/2010 03:30 PM, Hiroki Horiuchi wrote:
 How can I fix the problem?

The following works right now in Rakudo, but I don't know if it conforms
to the spec:

my $h = open '/dev/urandom', :bin;
$*OUT.write: $h.read(10)

note that read() returns a Buf, which can be printed out again with write().

Cheers,
Moritz


Re: reading binary stream?

2010-12-28 Thread Hiroki Horiuchi

Hello.


 Malformed UTF-8 string

   in 'IO::getc' at line 5457:CORE.setting


It was a bug of rakudo-star-2010.11.
recent copy of rakudo (8f10c4b94ea6) is free of this problem.

Regards,
Hiroki Horiuchi