/*
Split a string into an array of lines; unicode-aware
Original Source: <http://cocoa.karelia.com/Foundation_Categories/NSString/Split_Into_LInes.m>
(See copyright notice at <http://cocoa.karelia.com>)
*/

/*" Split a string into lines separated by any of the various newline characters. Equivalent to componentsSeparatedByString:@"\n" but it works with the different line separators: \r, \n, \r\n, 0x2028, 0x2029 "*/

- (NSArray *) componentsSeparatedByLineSeparators
{
NSMutableArray *result = [NSMutableArray array];
NSRange range = NSMakeRange(0,0);
unsigned start, end;
unsigned contentsEnd = 0;

while (contentsEnd < [self length])
{
[self getLineStart:&start end:&end contentsEnd:&contentsEnd forRange:range];
[result addObject:[self substringWithRange:NSMakeRange(start,contentsEnd-start)]];
range.location = end;
range.length = 0;
}
return result;
}