On Sun, Nov 14, 2010 at 12:52 AM, Nobuyoshi Nakada <nobu / ruby-lang.org> wrote:
> Hi,
>
> At Sun, 14 Nov 2010 09:42:00 +0900,
> Luis Lavena wrote in [ruby-core:33162]:
>> Please note that both line and encoded are printed correctly, but
>> extra characters are added. Also, when performing "chars" enumeration,
>> the output of both line and encoded are incorrect.
>
> I can't reproduce it on Windows Vista Japanese Edition.

What codepage and font are you using? In my case I'm using Consolas.

Also, Windows 7 x64.

> Any
> differences between the outputs at binary comparison?
>

The UTF-8 original byte sequence (line.bytes.to_a)
[195, 137, 115, 116, 97, 32, 101, 115, 32, 117, 110, 97, 32, 108, 195,
173, 110, 101, 97]

Windows-1252
[201, 115, 116, 97, 32, 101, 115, 32, 117, 110, 97, 32, 108, 237, 110, 101,7]

UTF-8 after Encoding.default_external
[195, 137, 115, 116, 97, 32, 101, 115, 32, 117, 110, 97, 32, 108, 195,
173, 110, 101, 97]

However, doing a debug, rb_w32_write, WriteFile seems to have 19 bytes
to write (len), but written is only 17.

Which then gets compared in io_binwrite (io.c) between len vs written
and offset turn in to byte 17, and remaining (n) into 2.

Then arg.ptr gets moved to the new offset and arg.length gets set to
2, generating the repetition of the last 2 bytes in the buffer.

(Apologizes for the naive debugging using GDB).

The issue shown here was raised by a RubyInstaller thread:

http://groups.google.com/group/rubyinstaller/msg/19104a7f9ef8d53e

We are looking to remove the need of win32console and leverage on
ANSICON. In the above message, Jason, author of that library, explain
the issue we are seeing here.

Please note that I don't have ANSICON installed on my system, so no
alteration from that could be affecting my results.

Nobu, perhaps you could think on another test script that could expose
better this issue?

Thank you.
-- 
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupy