"incomplete universal character name" with stringWithUTF8String
13,832
\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"];
Author by
Nasser
Updated on June 06, 2022Comments
-
Nasser almost 2 years
when i try to convert form utf-8 string to NSString like so:
NSString *s = [NSString stringWithUTF8String:"\U0627\U0644\U0641\U0631\U0646"]; NSLog(@"%@", s);
i get the compile error:
incomplete universal character name
note that it sometime just works fine:
NSString *UAE = [NSString stringWithUTF8String:"\U0627\U0644\U0641\U0631\U0646"]; NSLog(@"%@", UAE);
and the output:
الامارات
so why is that happening? please help.
-
Nasser about 14 yearsthanks alot Jack, however, im trying to parse the UTF-8 string from a webservice that i have no control over. Is space in the utf-8 string has any thing to do with issue. i mean how can I represent a space char in my case here? thanks again
-
David Gelhar about 14 yearsIf the string is coming from a webservice, how are you getting a compile-time error?
-
Nasser about 14 yearsactually i manually copied the utf-8 string from the dict returned and test it using the method -stringWithUTF8String, this is when i get compile-time error
-
Ben Thielker almost 8 yearsApple actually makes this error when recording events for UI tests. (As of Xcode 7.3 at least)