[#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:70706] [Ruby trunk - Bug #11519] "#{nil}" produces string as US-ASCII rather than current encoding
From:
pedz@...
Date:
2015-09-09 20:11:37 UTC
List:
ruby-core #70706
Issue #11519 has been updated by Perry Smith.
Nobuyoshi Nakada wrote:
> What's and why wrong?
=E2=80=9C#{bar}=E2=80=9D.encoding !=3D =E2=80=98UTF-8=E2=80=99 and =E2=80=
=9C#{bar}#{foo}=E2=80=9D.encoding !=3D =E2=80=98UTF-8=E2=80=99 despite foo =
being UTF-8 and the encoding of the source file and hence the =E2=80=9C =E2=
=80=A6 =E2=80=9C string within the source file being UTF-8.
----------------------------------------
Bug #11519: "#{nil}" produces string as US-ASCII rather than current encodi=
ng
https://bugs.ruby-lang.org/issues/11519#change-54095
* Author: Perry Smith
* Status: Feedback
* Priority: Normal
* Assignee:=20
* ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
~~~ruby
#! /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
puts "#{bar}#{foo}".encoding
~~~
The output for this on all versions of ruby that I have except 1.9.1 is thi=
s:
~~~
Ruby version: 2.2.3
__ENCODING__ =3D 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` used such a co=
nstruct so all my content was being converted to US-ASCII and sometimes wer=
e error off.
It seems to me the `"#{ ... }"` string should be utf-8 and so anything inse=
rted into it should be converted to utf-8 so `"#{nil}"` should be utf-8 -- =
not US-ASCII.
--=20
https://bugs.ruby-lang.org/