Re: Escaping spaces in paths
Re: Escaping spaces in paths
- Subject: Re: Escaping spaces in paths
- From: "Jose L. Hales-Garcia" <email@hidden>
- Date: Tue, 25 Jun 2002 10:42:08 -0700
On Tuesday, June 25, 2002, at 04:48 AM, Ondra Cada wrote:
s=[[s componentsSeparatedByString:@"!"]
componentsJoinedByString:@"\\!"]
Thank you. I encountered a bug with the handling of the backslash
though
(see below). It would be great for my work if Apple fixed it soon.
So far as I know, there's no bug, just that NSLog is not a *print*
method,
but a *debug* method, and therefore it happily shows escapes by a
kinda haphazard way, presumed to be the most readable one in console.
In the actual string, though, all should be all right (do check
yourself, eg. using characterAtIndex:).
I ran a test. The results are included below.
NSString *s = @"/test/ test/ test";
NSArray *arr = [s componentsSeparatedByString:@" "];
int i;
NSLog(@"s is %@", s);
for (i = 0; i < [arr count]; i++) {
NSLog(@"arr[%d] is %@", i, [arr objectAtIndex:i]);
}
s=[arr componentsJoinedByString:@"\\ "];
NSLog(@"s is now %@", s);
for (i = 0; i < [s length]; i++) {
NSLog(@"char in s at %d is %c", i, [s characterAtIndex:i]);
}
2002-06-25 10:34:57.628 R[532] s is /test/ test/ test
2002-06-25 10:34:57.628 R[532] arr[0] is /test/
2002-06-25 10:34:57.628 R[532] arr[1] is test/
2002-06-25 10:34:57.628 R[532] arr[2] is
2002-06-25 10:34:57.629 R[532] arr[3] is test
2002-06-25 10:34:57.629 R[532] s is now /test/\\\\ test/\\\\ \\\\ test
2002-06-25 10:34:57.629 R[532] char in s at 0 is /
2002-06-25 10:34:57.629 R[532] char in s at 1 is t
2002-06-25 10:34:57.629 R[532] char in s at 2 is e
2002-06-25 10:34:57.629 R[532] char in s at 3 is s
2002-06-25 10:34:57.629 R[532] char in s at 4 is t
2002-06-25 10:34:57.629 R[532] char in s at 5 is /
2002-06-25 10:34:57.629 R[532] char in s at 6 is \\\\
2002-06-25 10:34:57.629 R[532] char in s at 7 is
2002-06-25 10:34:57.629 R[532] char in s at 8 is t
2002-06-25 10:34:57.630 R[532] char in s at 9 is e
2002-06-25 10:34:57.630 R[532] char in s at 10 is s
2002-06-25 10:34:57.630 R[532] char in s at 11 is t
2002-06-25 10:34:57.630 R[532] char in s at 12 is /
2002-06-25 10:34:57.630 R[532] char in s at 13 is \\\\
2002-06-25 10:34:57.630 R[532] char in s at 14 is
2002-06-25 10:34:57.630 R[532] char in s at 15 is \\\\
2002-06-25 10:34:57.630 R[532] char in s at 16 is
2002-06-25 10:34:57.630 R[532] char in s at 17 is t
2002-06-25 10:34:57.630 R[532] char in s at 18 is e
2002-06-25 10:34:57.630 R[532] char in s at 19 is s
2002-06-25 10:34:57.630 R[532] char in s at 20 is t
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.