Project

General

Profile

Actions

Bug #9414

open

strftime returns incorrectly encoded string

Added by jimsong (Jimmy Song) over 8 years ago. Updated over 4 years ago.

Status:
Feedback
Priority:
Normal
Target version:
-
[ruby-core:<unknown>]

Description

On French Windows 7 with date set to July 1 2014 (summer daylight savings time):

C:\Ruby200\bin>irb
DL is deprecated, please use Fiddle
irb(main):001:0> Time.now.strftime("%Z")
=> "Centre (heure d\x92\xE9t\xE9)"
irb(main):002:0> Time.now.strftime("%Z").encoding
=> #<Encoding:CP850>
irb(main):003:0> puts Time.now.strftime("%Z")
Centre (heure dÆÚtÚ)
=> nil
irb(main):004:0> puts Time.now.strftime("%Z").force_encoding("CP1252")
Centre (heure d'été)
=> nil
irb(main):005:0>

It looks like the string that is returned by strftime here does not actually match the encoding that is applied to it? The returned bytes only make sense if interpreted as Windows-1252, not CP850. This is on a clean install of Ruby with no gems added.

Actions

Also available in: Atom PDF