diff options
author | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-10 02:06:51 +0000 |
---|---|---|
committer | nari <nari@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-10 02:06:51 +0000 |
commit | f04dd0f08b20ce48cc10fa88bab08b1941b3c558 (patch) | |
tree | 38e2cfebafb95593641a087f4553c0a10f620586 | |
parent | cf7ca7e66d2a03c7ce6783fd49b9c1b5411c707a (diff) |
* lib/irb/magic-file.rb: set a encoding, which is detected from
the file to read, to the internal encoding.
[Bug #4281][ruby-dev:43036]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/irb/magic-file.rb | 3 |
2 files changed, 8 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Mon Dec 10 10:36:12 2012 Narihiro Nakamura <authornari@gmail.com> + + * lib/irb/magic-file.rb: set a encoding, which is detected from + the file to read, to the internal encoding. + [Bug #4281][ruby-dev:43036] + Mon Dec 10 09:40:19 2012 Eric Hodel <drbrain@segment7.net> * lib/rubygems/ext/cmake_builder.rb: Added a builder for cmake. diff --git a/lib/irb/magic-file.rb b/lib/irb/magic-file.rb index 861262050e..339ed60b6b 100644 --- a/lib/irb/magic-file.rb +++ b/lib/irb/magic-file.rb @@ -8,9 +8,10 @@ module IRB line = io.gets line = io.gets if line[0,2] == "#!" encoding = detect_encoding(line) + internal_encoding = encoding encoding ||= default_src_encoding io.rewind - io.set_encoding(encoding, nil) + io.set_encoding(encoding, internal_encoding) if block_given? begin |