【问题标题】:What encoding should I use to encode temperautre symbol in my iOS development?在我的 iOS 开发中,我应该使用什么编码来编码温度符号?
【发布时间】:2012-12-03 14:42:13
【问题描述】:
char symbol[] = {0xa1,0xe3};  //temperatue symbol code

NSString *degree = [NSString stringWithCString:symbol encoding:NSASCIIStringEncoding];

//when "degree" displayed on screen,messy code.

我应该使用什么样的编码? NSASCIIStringEncoding 好像不行。

或者有其他方法可以帮助解决吗?

【问题讨论】:

    标签: ios encode temperature


    【解决方案1】:

    为什么要这么麻烦?直接在代码中输入度数符号?

    NSString *temp = [NSString stringWithFormat:@"%d °C", someVal]; // Char U+00B0
    

    更好的是 Unicode U+2103 () 或 U+2109 ()。

    【讨论】:

    • 感谢您的回答。因为如果从本地文件中读取符号值,我需要对其进行编码。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-24
    • 1970-01-01
    • 2015-10-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 2010-09-13
    相关资源
    最近更新 更多