【问题标题】:Convert UTF-8 to Traditional Chinese Characters将 UTF-8 转换为繁体中文字符
【发布时间】:2019-07-31 17:10:14
【问题描述】:

我似乎找不到可以让我执行以下操作的好的文档:

我有一堆 UTF-8 字符串 JSON'ed 到我的 iPhone 应用程序并显示到 UITableView。当用户点击一个项目时,我希望出现一个 UIActionSheet 来通知他们他们选择的类别。



问题在于,虽然中文字符在 UI​​TableView 中显示没有问题,但它们在 UIActionSheet 中显示为 UTF-8 字符。有没有办法把它从UTF-8转成繁体字?

我正在尝试这样做,但它不起作用:

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

提前致谢!

【问题讨论】:

    标签: iphone encoding internationalization cjk


    【解决方案1】:

    好的,经过进一步调查,这成功了:

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

    这成功了:


    【讨论】:

    • 答案中的链接/图像已失效。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-03
    • 2011-06-25
    • 2013-03-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多