Issue #5226 has been updated by Aaron Patterson.


OK. I will apply this patch.
----------------------------------------
Bug #5226: Encoding of Time#to_s
http://redmine.ruby-lang.org/issues/5226

Author: Aaron Patterson
Status: Open
Priority: Normal
Assignee: 
Category: M17N
Target version: 
ruby -v: ruby 1.9.4dev (2011-08-25 trunk 33051) [x86_64-darwin11.1.0]


I think the encoding of Time#to_s should default to US-ASCII, but respect Encoding.default_internal.  Today it always returns a binary string:

irb(main):001:0> Time.now.to_s.encoding
=> #<Encoding:ASCII-8BIT>
irb(main):002:0> Encoding.default_internal = Encoding::UTF_8
=> #<Encoding:UTF-8>
irb(main):003:0> Time.now.to_s.encoding
=> #<Encoding:ASCII-8BIT>
irb(main):004:0>

I've attached a patch to make Time#to_s respect Encoding.default_internal.  The result is:

irb(main):001:0> Encoding.default_internal
=> nil
irb(main):002:0> Time.now.to_s.encoding
=> #<Encoding:US-ASCII>
irb(main):003:0> Encoding.default_internal = Encoding::UTF_8
=> #<Encoding:UTF-8>
irb(main):004:0> Time.now.to_s.encoding
=> #<Encoding:UTF-8>
irb(main):005:0>


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