Cas*_*hew 6 c cocoa ascii objective-c
如何将ASCII值作为Cocoa中字符的int?我在python中找到了这样做的答案,但我需要知道如何在Cocoa中执行此操作.(我仍然是可可的菜鸟).
Python方法:
使用函数ord()如下:
>>> ord('a')
97
Run Code Online (Sandbox Code Playgroud)
而且反过来chr():
>>> chr(97)
'a'
Run Code Online (Sandbox Code Playgroud)
我怎么在Cocoa中做到这一点?
Mat*_*hen 12
字符常量已经是整数:
int aVal = 'a'; // a is 97, in the very likely event you're using ASCII or UTF-8.
Run Code Online (Sandbox Code Playgroud)
这与Cocoa没什么关系,Cocoa是一个库.它是C的一部分,所以它也不是Objective-C特有的.
| 归档时间: |
|
| 查看次数: |
4498 次 |
| 最近记录: |