Actions
Bug #5226
closedEncoding of Time#to_s
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.4dev (2011-08-25 trunk 33051) [x86_64-darwin11.1.0]
Backport:
Description
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>
Files
Actions
Like0
Like0Like0Like0