diff --git a/ChangeLog b/ChangeLog index cc4893b356..d09528a453 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jun 11 19:34:51 2011 Tadayoshi Funaba + + * ext/date/date_core.c (Date::(ABBR_)?(MONTH|DAY)NAMES): should be usascii. + Sat Jun 11 19:24:33 2011 Tadayoshi Funaba * ext/date/date_core.c: rewrote doc. diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 52402c7a20..9f6793e206 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -8114,7 +8114,7 @@ mk_ary_of_str(long len, const char *a[]) if (!a[i]) e = Qnil; else { - e = rb_str_new2(a[i]); + e = rb_usascii_str_new2(a[i]); rb_obj_freeze(e); } rb_ary_push(o, e); diff --git a/test/date/test_switch_hitter.rb b/test/date/test_switch_hitter.rb index 8f7accf793..d4603a23df 100644 --- a/test/date/test_switch_hitter.rb +++ b/test/date/test_switch_hitter.rb @@ -385,6 +385,19 @@ class TestSH < Test::Unit::TestCase end def test_enc + Date::MONTHNAMES.each do |s| + assert_equal(Encoding::US_ASCII, s.encoding) if s + end + Date::DAYNAMES.each do |s| + assert_equal(Encoding::US_ASCII, s.encoding) if s + end + Date::ABBR_MONTHNAMES.each do |s| + assert_equal(Encoding::US_ASCII, s.encoding) if s + end + Date::ABBR_DAYNAMES.each do |s| + assert_equal(Encoding::US_ASCII, s.encoding) if s + end + h = Date._strptime('15:43+09:00'.force_encoding('euc-jp'), '%R%z') assert_equal(Encoding::EUC_JP, h[:zone].encoding) h = Date._strptime('15:43+09:00'.force_encoding('ascii-8bit'), '%R%z')