Link to home
Start Free TrialLog in
Avatar of JohnGaby
JohnGabyFlag for Afghanistan

asked on

How do I declare a literal unicode string for the Mac

How do I declare a literal unicode string?  For example, with Windows I would simply use:

WCHAR text[]      = L"This is a unicode string";

For the Mac, I would like to do something like

UniChar text[] = L"This is a unicode string";

Now I know about CFSTR and CFStringRef, and that is not what I am looking for.  Is there a way to declare non-encapsulated literal unicode strings?
SOLUTION
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JohnGaby

ASKER

I am quite aware of the different flavors of unicode, and know that what is used it is OS dependent.  That is why I am asking questions about the Mac.  On the Mac, the basic string type is CFString, correct?  Now I can create this using a UTF8 string, or a UTF16 string (UniChar), but I don't see any way to create them using a UTF32 string.

I am a Windows programmer, so I am used to having my whole program use UTF16 strings everywhere.  I am also used to being able to index these strings, which I cannot do with CFString(?).  What I was wondering if there was a way to declare literal UTF16 (UniChar) strings for the Mac, or am I forced to use CFString everywhere?

OS X is Unix, so of course the type wchar_t is 32 bit, and therefore does not seem to be very useful in this context.
>> I am quite aware of the different flavors of unicode
Good, just wanted to be sure we're all on the same page -- it seems we are :)

>> OS X is Unix, so of course the type wchar_t is 32 bit, and therefore does not seem to be very useful in this context.
We handle all strings internally as UTF8 as it's the simplest way to provide cross-platform portability. We convert, if necessary, at the interface boundary.

Sorry, I don't know Macs so I can't advise specifically.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial