Fixed possible endian problems in NSString category. Universal buildable now.
[ITFoundation.git] / ITCategory-NSString.m
1 #import "ITCategory-NSString.h"
2
3 @implementation NSString (ITFoundationCategory)
4
5 + (id)stringWithFourCharCode:(unsigned long)fourCharCode {
6         return [[[self alloc] initWithFourCharCode:fourCharCode] autorelease];
7 }
8
9 - (id)initWithFourCharCode:(unsigned long)fourCharCode {
10         return UTCreateStringForOSType(fourCharCode);
11         //return [self initWithFormat:@"%.4s", &fourCharCode];
12 }
13
14 - (unsigned long)fourCharCode {
15         return UTGetOSTypeFromString((CFStringRef)self);
16         
17         //Die nasty bitshifting
18         /*const unsigned char *c_s = [self UTF8String];
19         unsigned long tmp = *c_s++;
20         tmp <<= 8;
21         tmp |= *c_s++;
22         tmp <<= 8;
23         tmp |= *c_s++;
24         tmp <<= 8;
25         return tmp |= *c_s++;*/
26 }
27
28 @end