gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implementing NSString getBytes


From: Luboš Doležel
Subject: Implementing NSString getBytes
Date: Sun, 09 Jun 2013 00:06:37 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

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 don't want that in this case 2) it doesn't tell you how many input characters were converted (which is understandable because of 1)

So I decided to use iconv() directly, which has a pitfall. I'd need to access static members (EntrySupported) of Unicode.m to know the iconv encoding's name etc. So I guess the iconv-related code (as attached) should be moved into Unicode.m.

===============

So I have a question: is it OK to write a function with declaration:

BOOL GSFromUnicodePartial(NSStringEncoding enc, int options, unichar **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);

that wouldn't suffer from 1) and 2) and add it into Source/Additions/Unicode.m next to GSFromUnicode()?

--
Luboš Doležel

Attachment: getBytes.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]