Skip to content

Instantly share code, notes, and snippets.

@pritchie
Created April 5, 2012 21:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pritchie/2314158 to your computer and use it in GitHub Desktop.
# ruby 1.9
# -*- coding: us-ascii -*-
s = '%s'
puts s.encoding # => US-ASCII
utf8_string = File.read('utf8_file')
puts utf8_string.encoding # => UTF-8
puts (s % utf8_string).encoding # => UTF-8
puts (s + utf8_string).encoding # => UTF-8
# jruby 1.6.7
# -*- coding: us-ascii -*-
s = '%s'
puts s.encoding # => US-ASCII
utf8_string = File.read('utf8_file')
puts utf8_string.encoding # => UTF-8
puts (s % utf8_string).encoding # => US_ASCII (oh crap!)
puts (s + utf8_string).encoding # => UTF-8puts s.encoding
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment