I am getting info using social framework and getting facebook info, when i get username in another language i.e Denis then it give me like "\U00e6\U00f8\U00e5", how to convert this string to readable string i.e Denis?
Asked
Active
Viewed 1,730 times
1
-
If this is just `NSLog()` output, then leave it as-is. It's just escaped when printed - the string contains the correct Unicode characters. – Sep 07 '13 at 06:15
-
@H2CO3 i have to use this username in creating profile,So i can not ignore this – Harin Sep 07 '13 at 06:16
-
So is it just `NSLog()` output, after all? Then you **can** ignore it. – Sep 07 '13 at 06:19
-
I just check the response in NSLog(),And it's display what I said.What actual I want,is to use that response to show in My Profile SignUp View which i create.So how I can convert it.? – Harin Sep 07 '13 at 06:22
-
You don't need to convert it. Again, it's escaped when logged, but the string itself contains the appropriate characters. – Sep 07 '13 at 06:22
-
@Harin - http://stackoverflow.com/questions/10305488/nsstring-to-const-char-convert-with-greek-characters – iPatel Sep 07 '13 at 06:23
-
@H2CO3 : i already try ,But it's Display in my View's textlable like : \U00e6\U00f8\U00e5 .. – Harin Sep 07 '13 at 06:27
-
1@Harin: `"\U00e6\U00f8\U00e5"` is `"æøå"`, is this your real output? - You could get better help if you show your code: How do you get the string? How do you print the string? – Martin R Sep 07 '13 at 07:59
5 Answers
0
I think these chracters are Unicode chracters, you can try something like this to convert them to UTF-8

sudhansu63
- 6,025
- 4
- 39
- 52
0
Try with following code
Your string that you got,
NSString *myStr = @".....
;
And use this code,
const wchar_t *myResulr = (const wchar_t*)[myStr cStringUsingEncoding:NSUTF16StringEncoding];
NSLog(@"\n str2 = %S",myResulr);
This also may be Helpful in your case.

iPatel
- 46,010
- 16
- 115
- 137
-
`NSUTF16StringEncoding` gives a sequence of `unichar`, which is 16-bit, but `wchar_t` is 32-bit, so this cannot work. - And note that the function `CFStringTokenizerCopyBestStringLanguage()` from your link guesses the *language*, not the *encoding*. – Martin R Sep 07 '13 at 07:48
0
Try this
NSString *str = [NSString stringWithUTF8String:"\u00e6\u00f8\u00e5"];
NSLog(@"%@", str);

Ravindhiran
- 5,304
- 9
- 50
- 82
0
I found this usefull solution for my problem. Check this link
OR
int main (int argc, const char * argv[])
{
@autoreleasepool {
NSString *name2escaped = @"\U00e6\U00f8\U00e5";
NSString *name2 = [NSString
stringWithCString:[name2escaped cStringUsingEncoding:NSUTF8StringEncoding]
encoding:NSNonLossyASCIIStringEncoding];
NSLog(@"name2 = %@", name2);
}
return 0;
}
0
Try:
NSString *str = @"\U00e6\U00f8\U00e5";
NSString *string = [NSString stringWithCString:[str UTF8String]
encoding:NSUTF8StringEncoding];
NSLog(@"string: %@", string);

MD SHAHIDUL ISLAM
- 14,325
- 6
- 82
- 89
-
Why should it help to convert the NSString to UTF-8 and back to NSString? That gives exactly the original string. – Martin R Sep 07 '13 at 07:51