String from code points?

M

Marcos

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).

Array#pack('U*') yields a UTF-8 string, but it's marked as
ASCII-8BIT.

Is there a preferred method?
 
B

Brian Candler

Ken said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top