“incomplete universal character name” with stringWithUTF8String

前端 未结 2 1420
后悔当初
后悔当初 2021-02-07 02:51

when i try to convert form utf-8 string to NSString like so:

NSString *s = [NSString stringWithUTF8String:\"\\U0627\\U0644\\U0641\\U0631\\U0646\"];
NSLog(@\"%@\"         


        
2条回答
  •  北海茫月
    2021-02-07 03:33

    \U and \u are not the same thing. The \U escape expects 8 (hex) digits instead of 4.

    This should work:

    NSString *s = [NSString stringWithUTF8String:"\u0627\u0644\u0641\u0631\u0646"];
    

提交回复
热议问题