none
2005-06-30 21:37:48 UTC
I have a stl::string (and thus, a null terminated C-string) and need to
create a CFStringRef. There's the CFSTR() macro, bit it only applies to
constant strings, not dynamic run-time strings. I have the following
code with some questions:
stl::string strTemp;
// .
// fill in strTemp
// .
// .
CFStringRef cfStringRef;
cfStringRef = CFStringCreateWithCString(kCFAllocatorDefault,
m_ strTemp.c_str(),
kCFStringEncodingMacRoman);
// .
// do something with cfStringRef
// .
// .
CFRelease(cfStringRef);
First, I'm using CFStringCreateWithCString() to create the CFStringRef.
Is there a better API to convert the C string to a CFStringRef?
Second, I'm passing kCFStringEncodingMacRoman for the CFStringEncoding
because, well, other code I've seen pass kCFStringEncodingMacRoman.
Will this hold up on non-English systems? What if I run my app on a
non-English system?
Thanks.
create a CFStringRef. There's the CFSTR() macro, bit it only applies to
constant strings, not dynamic run-time strings. I have the following
code with some questions:
stl::string strTemp;
// .
// fill in strTemp
// .
// .
CFStringRef cfStringRef;
cfStringRef = CFStringCreateWithCString(kCFAllocatorDefault,
m_ strTemp.c_str(),
kCFStringEncodingMacRoman);
// .
// do something with cfStringRef
// .
// .
CFRelease(cfStringRef);
First, I'm using CFStringCreateWithCString() to create the CFStringRef.
Is there a better API to convert the C string to a CFStringRef?
Second, I'm passing kCFStringEncodingMacRoman for the CFStringEncoding
because, well, other code I've seen pass kCFStringEncodingMacRoman.
Will this hold up on non-English systems? What if I run my app on a
non-English system?
Thanks.