Project

General

Profile

Actions

Bug #4097

closed

Unexpected result of STDIN.read on Windows

Added by phasis68 (Heesob Park) over 13 years ago. Updated over 12 years ago.

Status:
Third Party's Issue
Target version:
ruby -v:
ruby 1.9.3dev (2010-11-28 trunk 29965) [i386-mswin32_90]
Backport:
[ruby-core:33460]

Description

=begin
On Ruby 1.9.x, in case of non-ASCII input, STDIN.read(n) returns some garbage attached string.

C:\work>ruby -ve 'a=STDIN.read(10);p a;p a.length'
ruby 1.9.3dev (2010-11-28 trunk 29965) [i386-mswin32_90]
가나다라abcd
"\xB0\xA1\xB3\xAA\xB4\xD9\xB6\xF3ab\x00\x00\xB8t"
14

On the other hand, Ruby 1.8.6 works fine.

C:\work>ruby -ve 'a=STDIN.read(10);p a;p a.length'
ruby 1.8.6 (2010-02-04 patchlevel 398) [i386-mingw32]
가나다라abcd
"\260\241\263\252\264\331\266\363ab"
10
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0