# New Ticket Created by  Maxim Vuets 
# Please include the string:  [perl #123405]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123405 >


Rakudo+MoarVM dies on attempt to write to an utf16 file handle:

    $ perl6 -e '"привет".encode("utf-16")'
    $ perl6 -e '$f = open "foo.txt", :w, :enc<utf16>; $f.print("привет\n")'
    length out of range
      in method print at src/gen/m-CORE.setting:15821
      in block <unit> at -e:1

utf8 works just fine:

    $ perl6 -e '"привет".encode("utf-8")'
    $ perl6 -e '$f = open "foo.txt", :w, :enc<utf8>; $f.print("привет\n")'

Unsupported (yet) encodings are handled properly as well:

    $ perl6 -e '"привет".encode("cp1251")'
    Unknown string encoding: 'cp1251'
      in method encode at src/gen/m-CORE.setting:7136
        in block <unit> at -e:1
    $ perl6 -e '$f = open "foo.txt", :w, :enc<cp1251>; $f.print("привет\n")'
    Unknown string encoding: 'cp1251'
      in method open at src/gen/m-CORE.setting:15520
      in sub open at src/gen/m-CORE.setting:16577
      in block <unit> at -e:1

(My terminal encoding set to utf8.)

This is perl6 version 2014.11-75-gc91a583 built on MoarVM version 
2014.11-66-g23f2089

Reply via email to