How to convert a unichar value to an NSString in Objective-C?

前端 未结 5 1406
无人及你
无人及你 2020-11-29 00:32

I\'ve got an international character stored in a unichar variable. This character does not come from a file or url. The variable itself only stores an unsigned short(0xce91)

5条回答
  •  悲&欢浪女
    2020-11-29 01:09

    unichar greekAlpha = 0x0391;
    NSString* s = [NSString stringWithCharacters:&greekAlpha length:1];
    

    And now you can incorporate that NSString into another in any way you like. Do note, however, that it is now legal to type a Greek alpha directly into an NSString literal.

提交回复
热议问题