2010-06-29 12 views
1

Je ne peux pas sembler trouver une bonne documentation qui me permettra de faire ce qui suit:Convert UTF-8 pour les caractères chinois traditionnels

J'ai un tas de chaînes de caractères UTF-8 JSON'ed jusqu'à mon application iPhone et affichée dans un UITableView. Lorsque l'utilisateur clique sur un élément, je souhaite qu'une UIActionSheet apparaisse pour l'informer de la catégorie qu'il a sélectionnée.


alt text http://img684.imageshack.us/img684/4395/so20100629.png


Le problème est que si les caractères chinois apparaissent dans le UITableView sans problème, ils apparaissent comme caractères UTF-8 dans le UIActionSheet. Y a-t-il un moyen de le convertir de l'UTF-8 en caractères chinois traditionnels?

Je suis en train de le faire comme cela, mais il ne fonctionne pas:

const char *subCatName = [[thirdParamStringArr objectAtIndex:1] UTF8String]; 
    NSString *subCatSelectedConverted = [[NSString alloc] initWithUTF8String:subCatName];  

    NSString *actionSheetTitle = [@"You have selected " stringByAppendingString:subCatSelectedConverted]; 

    NSString *actionSheetTitleFinal = [actionSheetTitle stringByAppendingString:@", proceed to upload to selected subcategory?"]; 

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionSheetTitleFinal delegate:self cancelButtonTitle:@"Proceed to Upload" destructiveButtonTitle:@"Cancel" otherButtonTitles:nil]; 

Merci à l'avance!

Répondre

2

Ok, après enquête ce fait l'affaire:

NSString *subCatSelectedName = [[thirdParamStringArr objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 


     NSString *actionSheetTitle = [@"You have selected '" stringByAppendingString:subCatSelectedName]; 

     NSString *actionSheetTitleFinal = [actionSheetTitle stringByAppendingString:@"', proceed to upload to selected subcategory?"]; 

     UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionSheetTitleFinal delegate:self cancelButtonTitle:@"Proceed to Upload" destructiveButtonTitle:@"Cancel" otherButtonTitles:nil]; 

Ce fait le tour:


alt text http://img709.imageshack.us/img709/8703/so201006292.png

+0

Link/image réponse est morte. – Pang