Project

General

Profile

Bug #11519

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

~~~ruby ~~~
#! /usr/bin/env ruby
# encoding: utf-8

puts "Ruby version: #{RUBY_VERSION}"
puts "__ENCODING__ = #{__ENCODING__}"
puts "hello".encoding
foo = "hello"
puts "#{foo}".encoding
puts "#{"hello"}".encoding
bar = nil
puts "#{bar}".encoding
puts "#{nil}".encoding
puts "#{bar}#{foo}".encoding
~~~

The output for this on all versions of ruby that I have except 1.9.1 is this:

~~~
Ruby version: 2.2.3
__ENCODING__ = UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII
US-ASCII
~~~

It is the last part that gave me grief. Rails `content_for` content_for used such a construct so all my content was being converted to US-ASCII and sometimes were error off.

It seems to me the `"#{ "#{ ... }"` }" string should be utf-8 and so anything inserted into it should be converted to utf-8 so `"#{nil}"` "#{nil}" should be utf-8 -- not US-ASCII.

Back