Project

General

Profile

Actions

Bug #3533

closed

Default external encoding not picked up by output unless internal encoding set

Added by pdwilson12 (Peter Wilson) over 14 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
Target version:
ruby -v:
ruby 1.9.2dev (2010-07-02 revision 28522) [x86_64-darwin10.4.0]
Backport:
[ruby-core:31034]

Description

=begin
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.
=end


Files

EncodingTest.rb (579 Bytes) EncodingTest.rb pdwilson12 (Peter Wilson), 07/04/2010 11:01 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0