ios convert NSString with special chars to const char

自作多情 提交于 2019-12-13 03:53:37

问题


i m trying to draw a string with CGContextShowTextAtPoint. CGContextShowTextAtPoint only accepts "const char" as a string input. my problem is that some of the strings have special chars like ä,ö,ü etc in them.

if i convert this strings to a "const char"

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

i get a strange output, where the ü is replaced with signs and boxes...

what to do?


回答1:


You can draw only ASCII characters with CGContextShowTextAtPoint. To draw Unicode strings use either NSString UIKit Additions like drawInRect:withFont: or (for more customized drawing) CoreText framework.



来源:https://stackoverflow.com/questions/9910756/ios-convert-nsstring-with-special-chars-to-const-char

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!