Define unichar constants in code

I would like to do something like this:

const UniChar KA = 'か'; 

But Xcode returns a "multi-character constant."

I try not to use + characterAtIndex from NSString ... I need this to iterate over the kana, for example, you can char myCharacter = 'A'; over the alphabet ( char myCharacter = 'A'; )

I looked at Target c did not like my unichars? but that really doesn't solve it for me.

In any case, I try to put "tenten" and / or "maru" on top of か, た, etc., for example か β†’ が, た β†’ だ. Perhaps this is a ready-made solution for this, in case someone knows that it will also solve my problem.

+7
source share
1 answer

The source code is usually encoded as UTF-8, which means you cannot use 16-bit character literals. You must use the escape sequence:

 const UniChar KA = '\u30AB'; 

or indicate a numerical value:

 const unichar KA = 0x30AB; 

(Note: I really have no idea if this is the correct code for the example character you gave.)

I think your only option is to create a .strings file that can and should be encoded in UTF-16, and then get the characters into your program using NSLocalizedString .

+6
source

All Articles