views:

3197

answers:

2

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;

}
+2  A: 

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').

Alex Martelli
A: 

Be careful checking for newline that you know the format of your line endings, as Unix (and modern Mac) use \n, but Windows uses \r\n and classic Mac uses \r.

Peter N Lewis
Thanks. I've found a class, NSCharacterSet, that has a static method to produce NSNewlineCharacterSet which I can compare against.
LeeMobile