Re: Implementing NSString getBytes

2013-06-12 Thread Fred Kiefer
That code in CoreBase really looks quite nice. We should try to get more shared code between base and CoreBase, this could be a very good example. Of course with iconv as fallback when ICU isn't available and perhaps even a fallback for missing iconv. (BTW the UConverter element in the

Re: Implementing NSString getBytes

2013-06-12 Thread Maxthon Chan
Apple have already fused (most of) Foundation and CF into CoreFoundation.framework. We can totally combine them too - provide a libgnustep-corebase that contains (almost) all Foundation and all CoreFoundation, and a libgnustep-base that contains the rest of Foundation, linking against

Re: Implementing NSString getBytes

2013-06-12 Thread Stefan Bidi
On Wed, Jun 12, 2013 at 4:12 PM, Fred Kiefer fredkie...@gmx.de wrote: That code in CoreBase really looks quite nice. We should try to get more shared code between base and CoreBase, this could be a very good example. Of course with iconv as fallback when ICU isn't available and perhaps even a

Re: Implementing NSString getBytes

2013-06-12 Thread Ivan Vučica
On Wed, Jun 12, 2013 at 11:26 PM, Maxthon Chan xcvi...@me.com wrote: Also shining a light to the GUI side, how about combine Opal (CoreGraphics) and Back? Implement GUI using CoreGraphics functions as Apple did, and handle the backend issue with CoreGraphics. Yes. While not fusing, I'll be

Re: Implementing NSString getBytes

2013-06-10 Thread Richard Frith-Macdonald
On 8 Jun 2013, at 23:06, Luboš Doležel lu...@dolezel.info wrote: Hi, GNUstep's NSString currently lacks getBytes:maxLength:usedLength:encoding:options:range:remainingRange: (added in OS X 10.5). I wanted to implement this function, but GSFromUnicode()'s behavior is not the best fit

Re: Implementing NSString getBytes

2013-06-10 Thread Luboš Doležel
On Mon, 10 Jun 2013 07:58:29 +0100, Richard Frith-Macdonald wrote: 1) it fails if the output buffer is too small - we don't want that in this case Well, that depends on what arguments you pass to it ... if you provide it with a zone in which to allocate memory, it will allocate memory to make

Re: Implementing NSString getBytes

2013-06-10 Thread Richard Frith-Macdonald
On 10 Jun 2013, at 08:57, Luboš Doležel lu...@dolezel.info wrote: On Mon, 10 Jun 2013 07:58:29 +0100, Richard Frith-Macdonald wrote: 1) it fails if the output buffer is too small - we don't want that in this case Well, that depends on what arguments you pass to it ... if you provide it

Re: Implementing NSString getBytes

2013-06-10 Thread Luboš Doležel
On Mon, 10 Jun 2013 09:37:51 +0100, Richard Frith-Macdonald wrote: On 10 Jun 2013, at 08:57, Luboš Doležel lu...@dolezel.info wrote: On Mon, 10 Jun 2013 07:58:29 +0100, Richard Frith-Macdonald wrote: 1) it fails if the output buffer is too small - we don't want that in this case Well, that

Re: Implementing NSString getBytes

2013-06-10 Thread Richard Frith-Macdonald
On 10 Jun 2013, at 09:37, Richard Frith-Macdonald rich...@frithmacdonald.me.uk wrote: Given that GSFromUnicode() already does everything you want/need, apart from returning the number of characteers converted, it would seem obvious that the thing to do is simply tweak it to return that

Re: Implementing NSString getBytes

2013-06-10 Thread Luboš Doležel
On Mon, 10 Jun 2013 10:07:50 +0100, Richard Frith-Macdonald wrote: I think you are not looking at the whole documentation and/or code: If GSUniShortOk is set, the function will return a buffer containing any decoded characters even if the whole conversion fails. This means that it will

Re: Implementing NSString getBytes

2013-06-09 Thread Luboš Doležel
That would work, but it's extremely inefficient. I'd prefer to implement it using iconv. Lubos On 06/09/2013 04:23 AM, Chan Maxthon wrote: Slow to run but quick dirty: use -[NSString substringInRange:] to cut the string up, convert them into NSDatas and dump from them? 发自我的 iPhone 在

Re: Implementing NSString getBytes

2013-06-09 Thread Fred Kiefer
I like the idea of adding this functionality. You actual implementation wont do as you already noticed. We also cannot use iconv() unconditionally. I remember back in time when I first added a call to iconv() to GNUstep we also had to introduce the configure checks for it. And of course

Re: Implementing NSString getBytes

2013-06-09 Thread Stefan Bidi
I'm not too familiar with GSFromUnicode(), but couldn't you treat this function in the same way that CoreBase treats ucnv_fromUnicode()? That is, pass the buffer into GSFromUnicode() with GSUniStrict option. If it returns NO, adjust the src and use NULL for dst. Would that work? That said, I

Re: Implementing NSString getBytes

2013-06-09 Thread Luboš Doležel
On 06/09/2013 04:30 PM, Fred Kiefer wrote: I like the idea of adding this functionality. You actual implementation wont do as you already noticed. We also cannot use iconv() unconditionally. I remember back in time when I first added a call to iconv() to GNUstep we also had to introduce the

Implementing NSString getBytes

2013-06-08 Thread Luboš Doležel
Hi, GNUstep's NSString currently lacks getBytes:maxLength:usedLength:encoding:options:range:remainingRange: (added in OS X 10.5). I wanted to implement this function, but GSFromUnicode()'s behavior is not the best fit for this method: 1) it fails if the output buffer is too small - we

Re: Implementing NSString getBytes

2013-06-08 Thread Chan Maxthon
Can you just dump it from -[NSString dataUsingEncoding:] which is way simpler? 发自我的 iPhone 在 2013-6-9,6:06,Luboš Doležel lu...@dolezel.info 写道: Hi, GNUstep's NSString currently lacks getBytes:maxLength:usedLength:encoding:options:range:remainingRange: (added in OS X 10.5). I wanted

Re: Implementing NSString getBytes

2013-06-08 Thread Luboš Doležel
Unfortunately not. It would then be difficult to determine the leftover output argument's value. Also, when converting to UTF for example, there would be a risk of cutting a UTF sequence in the middle if it doesn't fit into the buffer argument when copying it from NSData. Simply put,

Re: Implementing NSString getBytes

2013-06-08 Thread Chan Maxthon
Slow to run but quick dirty: use -[NSString substringInRange:] to cut the string up, convert them into NSDatas and dump from them? 发自我的 iPhone 在 2013-6-9,6:16,Luboš Doležel lu...@dolezel.info 写道: Unfortunately not. It would then be difficult to determine the leftover output argument's