Project

General

Profile

Actions

Bug #5684

closed

[[Ruby 1.9:]] Socket doesn't respect default external encoding

Added by vovik (Vladimir Chernis) over 12 years ago. Updated about 12 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]
Backport:
[ruby-core:41385]

Description

When receiving data from a TCPSocket (as in client.rb, attached), the default internal encoding specified by the -E option to ruby is not respected.

Steps:
(1) In terminal window A, run: ruby server.rb
(2) In terminal window B, run: ruby -E ISO-8859-1 client.rb

Expected result for terminal window B:
bytes: "hell\xF6"
encoding: ISO-8859-1

Actual result for terminal window B:
bytes: "hell\xF6"
encoding: ASCII-8BIT

Workaround:
Use String#force_encoding('ISO-8859-1')


Files

client.rb (226 Bytes) client.rb ruby -E ISO-8859-1 client.rb vovik (Vladimir Chernis), 11/29/2011 11:35 AM
server.rb (440 Bytes) server.rb ruby server.rb vovik (Vladimir Chernis), 11/29/2011 11:35 AM
client.rb (221 Bytes) client.rb recv -> read vovik (Vladimir Chernis), 12/02/2011 10:17 AM
socket_vs_file.rb (188 Bytes) socket_vs_file.rb ruby -E ISO-8859-1 socket_vs_file.rb vovik (Vladimir Chernis), 12/02/2011 10:36 AM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0