Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Silence warning for Encoding.default_external=

  • Loading branch information...
commit e9a5ef475586f9565ea783632d6a4a25ce1aa874 1 parent 8d354bc
@jeremy jeremy authored
Showing with 5 additions and 9 deletions.
  1. +5 −9 activesupport/test/multibyte_utils_test.rb
View
14 activesupport/test/multibyte_utils_test.rb
@@ -120,20 +120,16 @@ def examples
end
if 'string'.respond_to?(:encoding)
+ KCODE_TO_ENCODING = Hash.new(Encoding::BINARY).
+ update('UTF8' => Encoding::UTF_8, 'SJIS' => Encoding::Shift_JIS)
+
def with_encoding(enc)
before = Encoding.default_external
+ silence_warnings { Encoding.default_external = KCODE_TO_ENCODING[enc] }
- case enc
- when 'UTF8'
- Encoding.default_external = Encoding::UTF_8
- when 'SJIS'
- Encoding.default_external = Encoding::Shift_JIS
- else
- Encoding.default_external = Encoding::BINARY
- end
yield
- Encoding.default_external = before
+ silence_warnings { Encoding.default_external = before }
end
else
alias with_encoding with_kcode
Please sign in to comment.
Something went wrong with that request. Please try again.