Changeset 8402
- Timestamp:
- 12/15/07 02:28:20 (9 months ago)
- Files:
-
- trunk/activesupport/lib/active_support/multibyte/chars.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/hash_ext_test.rb (modified) (2 diffs)
- trunk/activesupport/test/core_ext/module/attribute_aliasing_test.rb (modified) (1 diff)
- trunk/activesupport/test/json/encoding_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/multibyte/chars.rb
r6882 r8402 120 120 # +utf8_pragma+ checks if it can send this string to the handlers. It makes sure @string isn't nil and $KCODE is 121 121 # set to 'UTF8'. 122 def utf8_pragma? 123 !@string.nil? && ($KCODE == 'UTF8') 122 if RUBY_VERSION < '1.9' 123 def utf8_pragma? 124 !@string.nil? && ($KCODE == 'UTF8') 125 end 126 else 127 def utf8_pragma? 128 !@string.nil? && (Encoding.default_external == Encoding::UTF_8) 129 end 124 130 end 125 131 end trunk/activesupport/test/core_ext/hash_ext_test.rb
r8332 r8402 146 146 assert_equal updated_with_mixed['b'], 2 147 147 148 assert [updated_with_strings, updated_with_symbols, updated_with_mixed].all? { |hash| hash.keys.size == 2}148 assert [updated_with_strings, updated_with_symbols, updated_with_mixed].all? { |h| h.keys.size == 2 } 149 149 end 150 150 … … 372 372 373 373 def test_one_level_with_yielding 374 xml = { :name => "David", :street => "Paulina" }.to_xml(@xml_options) do |x ml|375 x ml.creator("Rails")374 xml = { :name => "David", :street => "Paulina" }.to_xml(@xml_options) do |x| 375 x.creator("Rails") 376 376 end 377 377 trunk/activesupport/test/core_ext/module/attribute_aliasing_test.rb
r7195 r8402 4 4 class Content 5 5 attr_accessor :title, :Data 6 6 7 def initialize 8 @title, @Data = nil, nil 9 end 10 7 11 def title? 8 12 !title.nil? 9 13 end 10 14 11 15 def Data? 12 16 !self.Data.nil? trunk/activesupport/test/json/encoding_test.rb
r8255 r8402 54 54 55 55 def test_utf8_string_encoded_properly_when_kcode_is_utf8 56 old_kcode, $KCODE = $KCODE, 'UTF8' 57 assert_equal '"\\u20ac2.99"', 'â¬2.99'.to_json 58 assert_equal '"\\u270e\\u263a"', 'ââº'.to_json 59 ensure 60 $KCODE = old_kcode 56 with_kcode 'UTF8' do 57 assert_equal '"\\u20ac2.99"', 'â¬2.99'.to_json 58 assert_equal '"\\u270e\\u263a"', 'ââº'.to_json 59 end 61 60 end 62 61 … … 81 80 82 81 protected 82 def with_kcode(code) 83 if RUBY_VERSION < '1.9' 84 begin 85 old_kcode, $KCODE = $KCODE, 'UTF8' 86 yield 87 ensure 88 $KCODE = old_kcode 89 end 90 else 91 yield 92 end 93 end 94 83 95 def object_keys(json_object) 84 96 json_object[1..-2].scan(/([^{}:,\s]+):/).flatten.sort