[MacRuby-devel] convert array into a string
Laurent Sansonetti
lsansonetti at apple.com
Mon Jan 10 13:19:25 PST 2011
Assuming your array contains ASCII fixnum representation of characters, messaging #pack('c*') on it should give you a string object back.
You can look up the documentation of Array#pack for more information.
I dislike this method, but here I don't see a better choice.
Laurent
On Jan 10, 2011, at 1:08 PM, Joel Reymont wrote:
> I would like to do
>
> mungedRegistration = [...]
> registrationString = NSString.stringWithUTF8String(mungedRegistration)
>
> but this results in
>
> can't convert Array into String (TypeError)
>
> What is the best approach here?
>
> I do need my munged registration to be an array since I'm initializing it with numbers and then do calculations on these numbers to convert them into character values.
>
> Thanks, Joel
>
> ---
> http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
>
>
>
>
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20110110/5f5a5436/attachment.html>
More information about the MacRuby-devel
mailing list