Project

General

Profile

Bug #13216

Updated by shyouhei (Shyouhei Urabe) about 7 years ago

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")' 
 ï

Back