Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IO::Handle.readchars incorrectly assumes all chars are 2 bytes long #6091

Open
p6rt opened this issue Feb 22, 2017 · 2 comments
Open

IO::Handle.readchars incorrectly assumes all chars are 2 bytes long #6091

p6rt opened this issue Feb 22, 2017 · 2 comments
Labels
IO JVM Related to Rakudo-JVM

Comments

@p6rt
Copy link

p6rt commented Feb 22, 2017

Migrated from rt.perl.org#130840 (status was 'new')

Searchable as RT130840$

@p6rt
Copy link
Author

p6rt commented Feb 22, 2017

From @zoffixznet

Based on the code, seems it's a naive kludge for the unimplemented nqp​::readcharsfh op. As a result, .readchars on JVM reads incorrect number
of chars, at times producing wrong data altogether​:

<ZoffixW> j​: "/tmp/Foo.pm6".IO.spurt​: "I♥u so very much"; "/tmp/Foo.pm6".IO.open.readchars(3).say
<camelia> rakudo-jvm fb4f16​: OUTPUT​: «I♥u ␤»
<ZoffixW> j​: "/tmp/Foo.pm6".IO.spurt​: "I love you so very much"; "/tmp/Foo.pm6".IO.open.readchars(3).say
<camelia> rakudo-jvm fb4f16​: OUTPUT​: «I love␤»
<ZoffixW> j​: "/tmp/Foo.pm6".IO.spurt​: "♥"; "/tmp/Foo.pm6".IO.open.readchars(1).say
<camelia> rakudo-jvm fb4f16​: OUTPUT​: «�␤»

@p6rt p6rt added IO JVM Related to Rakudo-JVM labels Jan 5, 2020
@usev6
Copy link

usev6 commented Nov 1, 2022

I'm of the opinion that this is caused by nqp::chars working on Java's UTF-16 chars, not on graphemes: Raku/nqp#783.

Just mentioning this here to link the two issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO JVM Related to Rakudo-JVM
Projects
None yet
Development

No branches or pull requests

2 participants