Guest User

Untitled

a guest
Nov 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. if RUBY_PLATFORM =~ /win|mingw/
  2.  
  3. require 'iconv'
  4.  
  5. alias old_puts puts
  6. alias old_gets gets
  7.  
  8. Iconv_outer = Iconv.new("cp866", "utf-8")
  9. Iconv_inner = Iconv.new("utf-8", "cp866")
  10.  
  11. def puts(*args)
  12. old_puts args.map { |p| p.is_a?(String) ? Iconv_outer.iconv(p) : p }
  13. end
  14.  
  15. def gets
  16. Iconv_inner.iconv(old_gets)
  17. end
  18. end
Add Comment
Please, Sign In to add comment