[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: String from code points?

Yukihiro Matsumoto

5/2/2009 12:26:00 AM

Hi,

In message "Re: String from code points?"
on Sat, 2 May 2009 05:45:04 +0900, Marcos <markjreed@gmail.com> writes:

|Given a(n array of) numeric value(s) representing (a) Unicode code
|point(s), how do I get a string of the indicated character(s)?
|
|Integer#chr doesn't seem to know about encodings; it just outputs the
|byte value (and fails for values that don't fit in a byte).

p 12354.chr
=> 12354 out of char range (RangeError)

p 12354.chr("utf-8")
=> ?

2 Answers

Ken

5/27/2009 12:00:00 PM

0

On May 2, 8:25 am, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:
> Hi,
>
> In message "Re: String from code points?"
> on Sat, 2 May 2009 05:45:04 +0900, Marcos <markjr...@gmail.com> writes:
>
> |Given a(n array of) numeric value(s) representing (a)Unicodecode
> |point(s), how do I get a string of the indicated character(s)?
> |
> |Integer#chr doesn't seem to know about encodings; it just outputs the
> |byte value (and fails for values that don't fit in a byte).
>
> p 12354.chr
> => 12354 out of char range (RangeError)
>
> p 12354.chr("utf-8")
> => ?

If the error happens then does it mean the ruby(http://
tryruby.hobix.com/) is using a old version? what version I should use
instead?

p 12354.chr("utf-8")
ArgumentError: wrong number of arguments (1 for
0)
from (irb):3:in
`chr'
from (irb):
3
from :0

Brian Candler

5/27/2009 3:00:00 PM

0

Ken wrote:
> If the error happens then does it mean the ruby(http://
> tryruby.hobix.com/) is using a old version?

Type RUBY_DESCRIPTION to see that it's running 1.8.7

All this encoding stuff requires 1.9.x. Matz's example works on 1.9.1
and 1.9.2.
--
Posted via http://www.ruby-....