Skip to content
This repository
Browse code

Silence warning for Encoding.default_external=

  • Loading branch information...
commit cce2112f12324f5e44e31060f840821c81b2dbf1 1 parent 91ffddc
Jeremy Kemper jeremy authored

Showing 1 changed file with 5 additions and 9 deletions. Show diff stats Hide diff stats

  1. +5 9 activesupport/test/multibyte_utils_test.rb
14 activesupport/test/multibyte_utils_test.rb
@@ -120,20 +120,16 @@ def examples
120 120 end
121 121
122 122 if 'string'.respond_to?(:encoding)
  123 + KCODE_TO_ENCODING = Hash.new(Encoding::BINARY).
  124 + update('UTF8' => Encoding::UTF_8, 'SJIS' => Encoding::Shift_JIS)
  125 +
123 126 def with_encoding(enc)
124 127 before = Encoding.default_external
  128 + silence_warnings { Encoding.default_external = KCODE_TO_ENCODING[enc] }
125 129
126   - case enc
127   - when 'UTF8'
128   - Encoding.default_external = Encoding::UTF_8
129   - when 'SJIS'
130   - Encoding.default_external = Encoding::Shift_JIS
131   - else
132   - Encoding.default_external = Encoding::BINARY
133   - end
134 130 yield
135 131
136   - Encoding.default_external = before
  132 + silence_warnings { Encoding.default_external = before }
137 133 end
138 134 else
139 135 alias with_encoding with_kcode

0 comments on commit cce2112

Please sign in to comment.
Something went wrong with that request. Please try again.