• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Confused re unichar
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Confused re unichar


  • Subject: Confused re unichar
  • From: Timothy Mowlem <email@hidden>
  • Date: Sat, 17 Feb 2007 16:09:43 +0000

Hello,

I am relatively new to Cocoa and I am confused over the exact definition of "unichar". In the Foundation documentation for NSString the type 'unichar' is mentioned at various places, e.g. method characterAtIndex:
It says:


Returns the character at a given array position.

- (unichar)characterAtIndex:(unsigned)index



Return Value

The character at the array position given by index.



Presumably a unichar is a single unicode character. But is it defined as 2 bytes in size (UTF-16) or is it variable (UTF-8)? I can't find its defintion anywhere.

Option double clicking brings up documentation that discusses unicode text generally but there was no specific mention of "unichar".

Where is the header file which declares "unichar"?



I am trying to write a simple category for NSString with some utility functions and here is the .h and .m:


#import <Foundation/NSString.h>


@interface NSString (TMString)

- (NSString *) stringByTrimmingWhitespace;
- (NSString *) stringByTrimmingWhitespaceAtStart;
- (NSString *) stringByTrimmingWhitespaceAtEnd;

@end




and



#import "TMString.h"

@implementation NSString (TMString)

- (NSString *) stringByTrimmingWhitespaceAtStart {
int length = [self length];
unichar *buffer = unichar[length];
[self getCharacters: buffer];
int idx = 0;
unichar ch;
while (idx < length) {
ch = buffer[idx++];
if (ch == '\x0020' || ch == '\x0009' || ch == '\x000A' || ch == '\x000D' || ch == '\x0085') {
continue;
}
break;
}
return [self substringFromIndex: idx];
}



The compiler complains with "error: parse error before unichar"



Anybody shed any light on my problem?



Thanks,

Tim
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Confused re unichar
      • From: Steve Christensen <email@hidden>
    • Re: Confused re unichar
      • From: Keary Suska <email@hidden>
    • Re: Confused re unichar
      • From: "stephen joseph butler" <email@hidden>
  • Prev by Date: Retain/Release vs. bindings: Who binds to me?
  • Next by Date: Re: Confused re unichar
  • Previous by thread: Retain/Release vs. bindings: Who binds to me?
  • Next by thread: Re: Confused re unichar
  • Index(es):
    • Date
    • Thread