From: jf Baillon Date: 2013-06-25T03:17:47+09:00 Subject: Ruby on Windows - Ouput char Fixnum on console It's my first post here, and I have some difficulties with english an with Ruby. Please can you give me some help. Ruby on Windows - Ouput char Fixnum on console. See attached file. After 'gem install win32-api --platform=ruby' in a command line The following program [between the lines ========] ======================== $stdout.sync=true require 'win32/api' include Win32 def put_cc car # Ouput char Fixnum on console a ||= API.new( '_putch', [], 'I', 'msvcrt') a.call(car) end print "test 200 \n" print 'ruby ', RUBY_VERSION, 'p', RUBY_PATCHLEVEL, " (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] " b = [72, 101, 108, 108, 111, 32, 82, 117, 98, 121, 10] print "\n" b.each { |i| put_cc i } put_cc 72 put_cc 101 put_cc 108.to_int put_cc 108 put_cc 111 put_cc 32 put_cc 82 put_cc 117 put_cc 98 put_cc 121 put_cc 10 'hola'.each_byte { |i| put_cc i } print "\n[Return] -> The end \n" gets ======================================= gives with Ruby 193 [between the ------------] ----------------------------- test 200 ruby 1.9.3p429 (2013-05-15) [i386-mingw32] Hello Ruby Hello Ruby hola [Return] -> The end ----------------------------- and with Ruby 2.0.0 ----------------------------- test 200 ruby 2.0.0p195 (2013-05-14) [x64-mingw32] ðððððððððððàààààààààààðððð [Return] -> The end ----------------------------- Attachments: http://www.ruby-forum.com/attachment/8534/Ouput_char_Fixnum_on_console.rtf -- Posted via http://www.ruby-forum.com/.