Question

Before start reading the question you've to know this so it'll be easy for you to understand the problem,

I've two strings verrà and verrà [see last character in both the strings -- the only difference]


I've these two strings verrà blah blah and verrà blah blah. As in my requirement, I need to show verrà blah blah based on condition, so I'll need to convert "verrÃ" to "verrà", I found that its unicode character and I can able to convert it by doing something like below,

//here, strText = @"verrà blah blah";
NSString *correctString = [NSString stringWithCString:[strText cStringUsingEncoding:NSISOLatin1StringEncoding] encoding:NSUTF8StringEncoding];

And it's working correctly for verrà blah blah, it converts it to verrà blah blah, But then I found that because of the above code, it stopped converting the already correct string that's verrà blah blah, because when this already correct string pass to the above code, it will be empty!

What I am doing wrong?

Was it helpful?

Solution

Finally I'd figure it out like this,

label.text = [label.text stringByReplacingOccurrencesOfString:@"Ã" withString:@"à"];

I got to know, some problems really don't need big attention or answer. I know this is a patch and not the proper way but helpful and time saver for now. Thanks everyone who've attended. :)

I'm still looking for some wide solution for such kind of conversation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top