[#79532] Immutable Strings vs Symbols — Daniel Ferreira <subtileos@...>

Hi,

15 messages 2017/02/15

[ruby-core:79542] [Ruby trunk Bug#13216] Possible unexpected behaviour reading string starting with a byte order mark

From: gabrielgiordanob@...
Date: 2017-02-15 20:58:15 UTC
List: ruby-core #79542
Issue #13216 has been reported by Gabriel Giordano.

----------------------------------------
Bug #13216: Possible unexpected behaviour reading string starting with a byte order mark
https://bugs.ruby-lang.org/issues/13216

* Author: Gabriel Giordano
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
Maybe the comparison between symbols has an unexpected behaviour. Tested with ruby 2.4.0

$ echo -n -e '\xEF\xBB\xBFid' | ruby -e 'puts STDIN.read.bytes'
239
187
191
105
100

$ echo -n -e 'id' | ruby -e 'puts STDIN.read.bytes'                                                                    
105
100

$ echo -n -e '\xEF\xBB\xBFid' | ruby -e 'puts STDIN.read.to_sym'
id

$ echo -n -e 'id' | ruby -e 'puts STDIN.read.to_sym'
id

$ echo -n -e '\xEF\xBB\xBFid' | ruby -e 'puts STDIN.read.to_sym == :id'                                                
false

$ echo -n -e 'id' | ruby -e 'puts STDIN.read.to_sym == :id'                                                            
true

$ echo -n -e '\xEF\xBB\xBFid' | ruby -e 'puts STDIN.read.bytes.pack("U")'
誰



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next