The win32console gem uses ANSI functions for writing to the console which doesn’t work for unicode strings, e.g. module tool. Ruby 1.9 does the same thing, but doesn’t account for ANSI escape sequences
# File lib/puppet/util/colors.rb, line 149 def Write(str) result = false FFI::MemoryPointer.from_string_to_wide_string(str) do |msg_ptr| FFI::MemoryPointer.new(:dword, 1) do |numberOfCharsWritten_ptr| result = WriteConsoleW(@handle, msg_ptr, str.length, FFI::MemoryPointer.new(:dword, 1), FFI::MemoryPointer::NULL) != FFI::WIN32_FALSE end end result end
# File lib/puppet/util/colors.rb, line 132 def WriteChar(str, col, row) writeCoord = COORD.new() writeCoord[:X] = row writeCoord[:Y] = col chars_written = 0 FFI::MemoryPointer.from_string_to_wide_string(str) do |msg_ptr| FFI::MemoryPointer.new(:dword, 1) do |numberOfCharsWritten_ptr| WriteConsoleOutputCharacterW(@handle, msg_ptr, str.length, writeCoord, numberOfCharsWritten_ptr) chars_written = numberOfCharsWritten_ptr.read_dword end end chars_written end
# File lib/puppet/util/colors.rb, line 128 def initialize(t = nil) super(t) end