[MacRuby-devel] convert array into a string
Caio Chassot
lists at caiochassot.com
Mon Jan 10 13:22:53 PST 2011
On 2011-01-10, at 19:19 , Laurent Sansonetti wrote:
>
> Assuming your array contains ASCII fixnum representation of characters, messaging #pack('c*') on it should give you a string object back.
>
> I dislike this method, but here I don't see a better choice.
numbers = [65, 195, 169]
s = numbers.map(&:chr).join
you may want to force the string to be treated as UTF-8.
s.force_encoding('UTF-8')
More information about the MacRuby-devel
mailing list