Issue #5232 has been updated by Yui NARUSE.


tadayoshi funaba wrote:
> why date?
> 
> > Encoding.default_internal = Encoding::UTF_8
> #=> #<Encoding:UTF-8>
> > 99e99.to_s.encoding 
> #=> #<Encoding:US-ASCII>
> 
> what's the difference?
> this is not a matter of date, anyway.

Yeah, even if Aaron's suggest is reasonable, it is the whale Ruby's issue;
This is not correct ticket about it.
----------------------------------------
Bug #5232: Encoding of Date#to_s
http://redmine.ruby-lang.org/issues/5232

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


The encoding of Date#to_s should respect Encoding.default_internal.

Here is the behavior today:

irb(main):001:0> require 'date'
=> true
irb(main):002:0> Date.today.to_s.encoding
=> #<Encoding:US-ASCII>
irb(main):003:0> Encoding.default_internal = Encoding::UTF_8
=> #<Encoding:UTF-8>
irb(main):004:0> Date.today.to_s.encoding
=> #<Encoding:US-ASCII>
irb(main):005:0>

Here is the behavior I expect:

irb(main):001:0> require 'date'
=> true
irb(main):002:0> Date.today.to_s.encoding
=> #<Encoding:US-ASCII>
irb(main):003:0> Encoding.default_internal = Encoding::UTF_8
=> #<Encoding:UTF-8>
irb(main):004:0> Date.today.to_s.encoding
=> #<Encoding:UTF-8>
irb(main):005:0>

I've attached a patch that fixes this.


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