Skip Menu |
Report information
Id: 132874
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: comdog <brian.d.foy [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: writing to utf16 handle gives write_fhb error
Date: Fri, 16 Feb 2018 03:55:40 -0500
From: brian d foy <brian.d.foy [...] gmail.com>
To: rakudobug [...] perl.org
Download (untitled) / with headers
text/plain 344b
This little program: my $fh = open 'test.txt', :w, :enc('utf16'); put "filehandle is using {$fh.encoding}"; $fh.put: 'Some text'; Gives this error: filehandle is using utf16 write_fhb requires a native array of uint8 or int8 ---- This is Rakudo Star version 2018.01 built on MoarVM version 2018.01 implementing Perl 6.c
RT-Send-CC: perl6-compiler [...] perl.org
Download (untitled) / with headers
text/plain 1.2k
On Fri, 16 Feb 2018 00:56:27 -0800, comdog wrote: Show quoted text
> This little program: > > my $fh = open 'test.txt', :w, :enc('utf16'); > put "filehandle is using {$fh.encoding}"; > $fh.put: 'Some text'; > > Gives this error: > > filehandle is using utf16 > write_fhb requires a native array of uint8 or int8 > > ---- > This is Rakudo Star version 2018.01 built on MoarVM version 2018.01 > implementing Perl 6.c
Looks like MoarVM doesn't fully support utf-16 yet (the exception is from MVM_io_read_bytes that just throws unless it's handed a 8-bit buf) Slightly golfed version: $ ./perl6 -e '"t.t".IO.open(:w :bin).write: utf16.new: 1, 2, 3' write_fhb requires a native array of uint8 or int8 in block <unit> at -e line 1 $ ./perl6 -e '"t.t".IO.open(:w :bin).write: utf32.new: 1, 2, 3' write_fhb requires a native array of uint8 or int8 in block <unit> at -e line 1 $ ./perl6 -e '"t.t".IO.open(:w :bin).write: buf32.new: 1, 2, 3' write_fhb requires a native array of uint8 or int8 in block <unit> at -e line 1 Dies on read too, but with a more useful message: $ ./perl6 -e '"LICENSE".IO.open(:enc<utf-16>).slurp.say' Streaming decode NYI for encoding 4 in block <unit> at -e line 1 Works fine on JVM backend.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org