I get data from a UTF-8 encoded XML file, and I want to display every element in a UITableView . I want my cells to have the same size and display the 2 first text lines with the most data possible so I tried to remove the carriage returns.
In my cellForRow method I changed this :
[[myCell textLabel] setText:data];
By :
[[myCell textLabel] setText:[self correctData:data]];
Here is my correctData method :
- (NSString *) correctData : (NSString *) str
{
NSMutableString *res = [NSMutableString stringWithFormat:@""];
for(int i = 0 ; i < [str length] ; i++)
{
char car = [str characterAtIndex:i];
if(car != 10 && car != 13)
[res appendString:[NSString stringWithFormat:@"%c",car]];
}
return res;
}
And this correctly removes the carriage returns, but it also alters the UTF-8 chars. For example, a bit of the initial string (str) :
Diplômé(e) d'Etat
And with this function it becomes :
DiplÙmÈ(e) d'Etat
What should I do ? Thanks.