【问题标题】:ios convert NSString with special chars to const charios 将带有特殊字符的 NSString 转换为 const char
【发布时间】:2012-04-12 05:41:03
【问题描述】:

我正在尝试使用 CGContextShowTextAtPoint 绘制一个字符串。 CGContextShowTextAtPoint 只接受“const char”作为字符串输入。 我的问题是某些字符串中包含特殊字符,例如 ä,ö,ü 等。

如果我将此字符串转换为“const char”

NSString *label = @"Küche";
const char *charLabel = [label UTF8String];

我得到一个奇怪的输出,其中 ü 被符号和框替换...

怎么办?

【问题讨论】:

    标签: ios nsstring char nsstringencoding


    【解决方案1】:

    CGContextShowTextAtPoint 只能绘制 ASCII 字符。 要绘制 Unicode 字符串,请使用 NSString UIKit Additions,如 drawInRect:withFont: 或(用于更自定义的绘图)CoreText framework

    【讨论】:

      猜你喜欢
      • 2012-02-24
      • 1970-01-01
      • 2012-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-09
      • 1970-01-01
      相关资源
      最近更新 更多