[MacRuby-devel] A ruby string with ASCII-8BIT encoding is really an NSData and not an NSString

2010-05-28 Thread Carl Lerche
Hello, I've been playing around with macruby a bunch and I hit a point of confusion. I basically did "".pack("H*") which returns a ruby string. This string is an ASCII-8BIT encoded ruby string which is an alias for a Binary string (aka, it has no encoding). IMO, this should really be backed by

Re: [MacRuby-devel] A ruby string with ASCII-8BIT encoding is really an NSData and not an NSString

2010-05-28 Thread Josh Ballanco
On May 28, 2010, at 10:03 AM, Carl Lerche wrote: > Hello, Hi! > I've been playing around with macruby a bunch and I hit a point of > confusion. I basically did "".pack("H*") which returns a ruby > string. This string is an ASCII-8BIT encoded ruby string which is an > alias for a Binary strin

Re: [MacRuby-devel] A ruby string with ASCII-8BIT encoding is really an NSData and not an NSString

2010-05-28 Thread Laurent Sansonetti
Hi Carl, Why not using -[NSString dataUsingEncoding:]? It would be better perf wise than constructing a bytes array like you do. As Josh mentioned, the fact that the String class can hold arbitrary data (not only characters) is a design issue of Ruby that we unfortunately need to follow for co

Re: [MacRuby-devel] A ruby string with ASCII-8BIT encoding is really an NSData and not an NSString

2010-05-28 Thread Carl Lerche
Laurent, There is no NS* encoding that will correctly return the data from the ASCII-8BIT encoded string without mangling it (as far as I could figure out at least, I spent a good deal of time trying to). Basically, there was no way to get a data object using the NSString data* methods. My general

Re: [MacRuby-devel] A ruby string with ASCII-8BIT encoding is really an NSData and not an NSString

2010-05-28 Thread Laurent Sansonetti
I see... you're right. I guess adding a #to_data method makes sense then. Could you file a ticket on trac? I believe the method should only work for Ruby strings and raise an exception for NSStrings. Laurent On May 28, 2010, at 1:41 PM, Carl Lerche wrote: > Laurent, > > There is no NS* enc

[MacRuby-devel] [MacRuby] #732: Ruby strings should have a to_data method

2010-05-28 Thread MacRuby
#732: Ruby strings should have a to_data method ---+ Reporter: m...@… | Owner: lsansone...@… Type: enhancement| Status: new Priority: minor |

Re: [MacRuby-devel] A ruby string with ASCII-8BIT encoding is really an NSData and not an NSString

2010-05-28 Thread Carl Lerche
Alright, Here is the ticket: https://www.macruby.org/trac/ticket/732 -carl On Fri, May 28, 2010 at 1:59 PM, Laurent Sansonetti wrote: > I see... you're right.  I guess adding a #to_data method makes sense then. > Could you file a ticket on trac? > > I believe the method should only work for Ru