Objective-C的:将unichar主场迎战字符 [英] Objective-C: unichar vs. char

查看:192
本文介绍了Objective-C的:将unichar主场迎战字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个unichar和一个char之间有点困惑。我可以把将unichar是类似烧焦的?

例如,我可以这样做:

   - (BOOL)isNewLine:(为unichar)C {如果(C =='\\ n')
  返回YES;
其他
  返回NO;}


解决方案

是,将unichar是内部无符号短,所以你可以有意识的将其与<$ C $比较C>字符(如果后者是ASCII,不过这对于的'\\ n')。

I'm a little confused between a unichar and a char. Can I treat unichar's similar to char's?

For example, can I do this:

-(BOOL)isNewLine:(unichar)c {

if(c == '\n')
  return YES;
else
  return NO;

}

解决方案

Yes, unichar is internally unsigned short, so you can meaningfully compare it with a char (if the latter is ASCII, but that works fine for '\n').

这篇关于Objective-C的:将unichar主场迎战字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆