Project

General

Profile

Actions

Feature #4224

closed

inconsistent behavior of 'puts "\xFF"'

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

Status:
Closed
Target version:
[ruby-core:33999]

Description

=begin
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)) {
    =end
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0