FROM : Jens Alfke
DATE : Sun May 11 22:38:58 2008
On 11 May '08, at 10:36 AM, Steve Cronin wrote:
> const char * cPartNumber = [partNumber
> cStringUsingEncoding:NSUTF8StringEncoding];
That looks correct, assuming the Carbon function does take a C string
in UTF-8 encoding, but you can make it a bit more compact:
const char * cPartNumber = [partNumber UTF8String];
> (char *) cPartNumber,
It would be a good idea to check whether that function takes a char*
(instead of const char*) because it actually writes back into the
string, or because someone just forgot to put a "const" in its
declaration. Most likely it's the latter, but in the former case
there's a chance it could blow up the heap if it decides to overwrite
the C string generated by the NSString.
—Jens
DATE : Sun May 11 22:38:58 2008
On 11 May '08, at 10:36 AM, Steve Cronin wrote:
> const char * cPartNumber = [partNumber
> cStringUsingEncoding:NSUTF8StringEncoding];
That looks correct, assuming the Carbon function does take a C string
in UTF-8 encoding, but you can make it a bit more compact:
const char * cPartNumber = [partNumber UTF8String];
> (char *) cPartNumber,
It would be a good idea to check whether that function takes a char*
(instead of const char*) because it actually writes back into the
string, or because someone just forgot to put a "const" in its
declaration. Most likely it's the latter, but in the former case
there's a chance it could blow up the heap if it decides to overwrite
the C string generated by the NSString.
—Jens
| Related mails | Author | Date |
|---|---|---|
| Steve Cronin | May 11, 19:36 | |
| Nick Zitzmann | May 11, 19:59 | |
| Jens Alfke | May 11, 22:38 | |
| Steve Cronin | May 12, 00:11 | |
| Nick Zitzmann | May 12, 00:14 | |
| Scott Ribe | May 12, 19:41 |






Cocoa mail archive

