[#70843] Re: [ruby-cvs:58952] hsbt:r51801 (trunk): * lib/rubygems: Update to RubyGems HEAD(fe61e4c112). — Eric Wong <normalperson@...>
hsbt@ruby-lang.org wrote:
3 messages
2015/09/17
[ruby-core:70693] Possible encoding bug
From:
Perry Smith <pedzsan@...>
Date:
2015-09-08 20:38:35 UTC
List:
ruby-core #70693
Hi,
I=E2=80=99ve been tracking down a bug in Rails but finally came done to =
what might be a bug in Ruby.
Here is my sample code:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
#! /usr/bin/env ruby
# encoding: utf-8
puts "Ruby version: #{RUBY_VERSION}"
puts "__ENCODING__ =3D #{__ENCODING__}"
puts "hello".encoding
foo =3D "hello"
puts "#{foo}".encoding
puts "#{"hello"}".encoding
bar =3D nil
puts "#{bar}".encoding
puts "#{nil}".encoding
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
The short of it is for all versions of Ruby except 1.9.1 that I tested =
(including the latest 2.2.3)
bar =3D nil
=E2=80=9C#{bar}=E2=80=9D.encoding =3D> US-ASCII
which seems inconsistent to me. In Ruby 1.9.1 it is UTF-8
Here is the output from the program above with various versions of Ruby
Ruby version: 1.9.1
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
UTF-8
UTF-8
Ruby version: 1.9.3
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII
Ruby version: 1.9.3
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII
Ruby version: 2.0.0
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII
Ruby version: 2.1.0
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII
Ruby version: 2.1.2
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII
Ruby version: 2.1.4
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII
Ruby version: 2.2.3
__ENCODING__ =3D UTF-8
UTF-8
UTF-8
UTF-8
US-ASCII
US-ASCII