Issue #7752 has been updated by naruse (Yui NARUSE).

Status changed from Open to Rejected

On current policy, strings which always include only US-ASCII characters are US-ASCII.
If there is a practical issue, I may change the policy in the future.

Note that US-ASCII string is faster than UTF-8 on getting length or index access.
----------------------------------------
Bug #7752: Rational/Float/Fixnum/Bignum `.to_s.encoding` is US-ASCII
https://bugs.ruby-lang.org/issues/7752#change-35755

Author: coffeejunk (Maximilian Haack)
Status: Rejected
Priority: Normal
Assignee: 
Category: core
Target version: 2.0.0
ruby -v: 2.0.0dev


=begin
When converting an instance of Rational/Float/Fixnum/Bignum to a string with the (({.to_s})) method, the resulting string has the encoding US-ASCII. This happens for 1.9.3 as well as 2.0.0rc1.

(({> __ENCODING__}))
(({ => #<Encoding:UTF-8>})) 

(({> Encoding.default_internal}))
(({ => #<Encoding:UTF-8>})) 

(({> Encoding.default_external}))
(({ => #<Encoding:UTF-8>})) 

(({> 1.to_s.encoding}))
(({#=> #<Encoding:US-ASCII>}))

(({> (2/1).to_r.to_s.encoding}))
(({ => #<Encoding:US-ASCII>}))

(({> "abc".encoding}))
(({ => #<Encoding:UTF-8>}))

=end


-- 
http://bugs.ruby-lang.org/