Re: Integer#chr

Kim Pedersen <[email protected]> Sun, 25 Aug 2019 17:35:24 +0200
Newsgroups gmane.comp.lang.ruby.general
Message-ID <[email protected]>
Hi 

The german umlaut Ä has unicode number U+00C4, which in UTF-8 encoding
becomes "\xC3\x84". 

irb> puts "\u00c4" => Ä 

irb> puts "\xc3\x84".force_encoding 'UTF-8' => Ä 

The number 0xc384 interpreted as a unicode point is a korean character. 

Best regards 

Kim 

Den 24.08.2019 20:01, skrev Detlef Wagner:

> Hi,
> 
> i have a problem with Integer#chr, where the encoding is UTF-8. If I call
> 
> 0xC384.chr(Encoding::UTF_8)
> 
> in irb, I expect the German umlaut Ä, but I get 쎄, where I even can't
> say what language it is ;-)
> 
> Is it a bug, or do I something wrong?
> 
> Cheers, detlef
> 
> ruby version ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-linux-gnu]
> irb version 0.9.6(09/06/30)
> 
> Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>