Question

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?

Was it helpful?

Solution 4

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;
}

OTHER TIPS

I think these chracters are Unicode chracters, you can try something like this to convert them to UTF-8

http://effbot.org/zone/unicode-convert.htm

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.

Try this

NSString *str = [NSString stringWithUTF8String:"\u00e6\u00f8\u00e5"];
NSLog(@"%@", str);

Try:

NSString *str = @"\U00e6\U00f8\U00e5";

NSString *string = [NSString stringWithCString:[str UTF8String]  
                        encoding:NSUTF8StringEncoding];

NSLog(@"string: %@", string);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top