Re: representing TABs in NSString.
Re: representing TABs in NSString.
- Subject: Re: representing TABs in NSString.
- From: Kurt Revis <email@hidden>
- Date: Sun, 2 Dec 2001 10:26:20 -0800
On Sunday, December 2, 2001, at 08:24 AM, Max Horn wrote:
At 1:59 Uhr -0500 02.12.2001, Jake wrote:
How does one delete tab from a mutable character set? I tried
wanttab = [[NSCharacterSet whitespaceCharacterSet] mutableCopy];
[wanttab removeCharactersInString:@"\t"];
While @"\t" and @"\x09" works for
- NSString componentsSeparatedByString:
they fails for
- NSMutableCharacterSet removeCharactersInString:
each time it is recognized as '\' and 't' instead of a tab.
From the top of my head, try:
[wanttab removeCharactersInRange:NSMakeRange('\t',1)];
You really shouldn't have to do that, though. There is nothing special
about the tab character; something else is wrong in your code. Here's
my test:
{
NSString *tabString = @"\t";
NSMutableCharacterSet *charSet;
NSLog(@"string length (should be 1): %u", [tabString length]);
charSet = [[NSCharacterSet controlCharacterSet] mutableCopy];
NSLog(@"is tab in controlCharacterSet? (should be 1): %d",
[charSet characterIsMember:'\t']);
[charSet removeCharactersInString:tabString];
NSLog(@"is tab in charSet? (should be 0): %d", [charSet
characterIsMember:'\t']);
}
The results are
string length (should be 1): 1
is tab in controlCharacterSet? (should be 1): 1
is tab in charSet? (should be 0): 0
so it appears to work just fine.
--
Kurt Revis
email@hidden