Issue #5232 has been updated by Aaron Patterson.


I think what I'm trying to say is: why does US-ASCII play a role?

It seems if someone sets default_internal, then strings should either be ASCII-8BIT *or* default_internal.
----------------------------------------
Bug #5232: Encoding of Date#to_s
http://redmine.ruby-lang.org/issues/5232

Author: Aaron Patterson
Status: Open
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