From: Peter Wilson Date: 2010-07-04T11:01:54+09:00 Subject: [ruby-core:31034] [Bug #3533] Default external encoding not picked up by output unless internal encoding set Bug #3533: Default external encoding not picked up by output unless internal encoding set http://redmine.ruby-lang.org/issues/show/3533 Author: Peter Wilson Status: Open, Priority: Normal Category: core, Target version: 1.9.2 ruby -v: ruby 1.9.2dev (2010-07-02 revision 28522) [x86_64-darwin10.4.0] ruby 1.9.2dev (2010-07-02 revision 28522) [x86_64-darwin10.4.0] If I specify an external encoding with the -E option, the STDOUT and File.open output streams do not respect it. I have to explicitly assign an external encoding on the stream, otherwise strings written to the stream are not transcoded; instead the raw byes of the strings are written out. However, if I set a default internal encoding with the -E option, it all works. Strings with some arbitrary encoding are transcoded into the default external encoding when written to the stream. I've attached a sample program illustrating this. It logs ruby's default encodings, the encodings of STDOUT and STDIN, and then writes an ISO-8859-1 and UTF-8 string to a new file opened without an explicit encoding. If I run the script with '-E utf-8', STDOUT and the file don't list any external encoding and the generated file has text of both encodings present. If I instead run it with '-E utf-8:utf-8', adding an *internal* encoding, all streams get the UTF-8 external encoding and the generated file contains the correct UTF-8 versions of both strings. ---------------------------------------- http://redmine.ruby-lang.org