From: Heesob Park Date: 2010-12-29T23:42:43+09:00 Subject: [ruby-core:33999] [Ruby 1.9-Feature#4224][Open] inconsistent behavior of 'puts "\xFF"' Feature #4224: inconsistent behavior of 'puts "\xFF"' http://redmine.ruby-lang.org/issues/show/4224 Author: Heesob Park Status: Open, Priority: Normal Category: core, Target version: 1.9.3 C:\work>ruby -ve 'puts "\xFFabc"' ruby 1.9.3dev (2010-12-28 trunk 30412) [i386-mswin32_90] -e:1:in `write': "\xFF" on CP949 (Encoding::InvalidByteSequenceError) from -e:1:in `puts' from -e:1:in `puts' from -e:1:in `
' $ ruby -ve 'puts "\xFFabc"' ruby 1.9.3dev (2010-12-02) [i686-linux] abc C:\>ruby -ve 'puts "\xFFabc"' ruby 1.9.2p136 (2010-12-25) [i386-mingw32] abc The trunk version raises Encoding::InvalidByteSequenceError on Windows. But, on the other version and other platform, it works without error. What is the proper behavior? I think this error could be avoided by following patch: --- win32.c 2010-12-28 13:59:30.000000000 +0900 +++ win32.c.new 2010-12-28 14:00:18.000000000 +0900 @@ -5312,7 +5312,7 @@ !rb_econv_has_convpath_p(rb_enc_name(rb_enc_get(str)), "UTF-16LE")) return -1L; - str = rb_str_encode(str, rb_enc_from_encoding(rb_enc_find("UTF-16LE")), 0, + str = rb_str_encode(str, rb_enc_from_encoding(rb_enc_find("UTF-16LE")), ECONV_INVALID_REPLACE|ECONV_UNDEF_REPLACE, Qnil); if (!WriteConsoleW(handle, (LPWSTR)RSTRING_PTR(str), RSTRING_LEN(str)/2, &reslen, NULL)) { ---------------------------------------- http://redmine.ruby-lang.org