Project

General

Profile

Actions

Bug #9414

closed

strftime returns incorrectly encoded string

Added by jimsong (Jimmy Song) about 10 years ago. Updated about 6 years ago.

Status:
Feedback
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 #1

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Status changed from Open to Feedback

What's your system codepage, 850 or 1252?

Actions #2

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Description updated (diff)
Actions #3

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • ruby -v changed from ruby 2.0.0p353 (2013-11-22) [i386-mingw32] to -

Issue #9414 has been updated by Nobuyoshi Nakada.

Status changed from Open to Feedback

What's your system codepage, 850 or 1252?


Bug #9414: strftime returns incorrectly encoded string
https://bugs.ruby-lang.org/issues/9414#change-44351

  • Author: Jimmy Song
  • Status: Feedback
  • Priority: Normal
  • Assignee: Nobuyoshi Nakada
  • Category: platform/mingw
  • Target version: current: 2.2.0
  • ruby -v: ruby 2.0.0p353 (2013-11-22) [i386-mingw32]
  • Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN

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.

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

Actions #4

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

Issue #9414 has been updated by Nobuyoshi Nakada.

Description updated


Bug #9414: strftime returns incorrectly encoded string
https://bugs.ruby-lang.org/issues/9414#change-44352

  • Author: Jimmy Song
  • Status: Feedback
  • Priority: Normal
  • Assignee: Nobuyoshi Nakada
  • Category: platform/mingw
  • Target version: current: 2.2.0
  • ruby -v: ruby 2.0.0p353 (2013-11-22) [i386-mingw32]
  • Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN

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.

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

Actions #5

Updated by jimsong (Jimmy Song) about 10 years ago

How do I determine the system code page?

Actions #6

Updated by jimsong (Jimmy Song) about 10 years ago

Ah, ok, I think I got it:

C:\Ruby200\bin>chcp
Page de codes active : 850

Actions #7

Updated by jimsong (Jimmy Song) about 10 years ago

Issue #9414 has been updated by Jimmy Song.

How do I determine the system code page?


Bug #9414: strftime returns incorrectly encoded string
https://bugs.ruby-lang.org/issues/9414#change-44358

  • Author: Jimmy Song
  • Status: Feedback
  • Priority: Normal
  • Assignee: Nobuyoshi Nakada
  • Category: platform/mingw
  • Target version: current: 2.2.0
  • ruby -v: -
  • Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN

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.

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

Actions #8

Updated by jimsong (Jimmy Song) about 10 years ago

Issue #9414 has been updated by Jimmy Song.

Ah, ok, I think I got it:

C:\Ruby200\bin>chcp
Page de codes active : 850


Bug #9414: strftime returns incorrectly encoded string
https://bugs.ruby-lang.org/issues/9414#change-44359

  • Author: Jimmy Song
  • Status: Feedback
  • Priority: Normal
  • Assignee: Nobuyoshi Nakada
  • Category: platform/mingw
  • Target version: current: 2.2.0
  • ruby -v: -
  • Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN

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.

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

Actions #9

Updated by naruse (Yui NARUSE) about 6 years ago

  • Target version deleted (2.2.0)
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0