Hi, I try to replace "'" with "\'", and also "\\" with "\\\\" using NSString's stringByReplacingOccurrencesOfString.
When I for example do this: escapedFileName = [@"this is a string blah" stringByReplacingOccurrencesOfString:@"blah" withString:@"blubb"]; NSLog(@"escapedFileName: %@", escapedFileName); Then it prints out: escapedFileName: this is a string blubb So far, so good. but when I then try to: escapedFileName = [@"this is a string' blah" stringByReplacingOccurrencesOfString:@"'" withString:@"\'"]; then the NSLog prints out: escapedFileName: this is a string' blah also when I try: escapedFileName = [@"this is a string' blah" stringByReplacingOccurrencesOfString:@"'" withString:@"XXX"]; its still printing: escapedFileName: this is a string' blah also I have a problem when I try to escape \ characters: escapedFileName = [@"this is a string\ blah" stringByReplacingOccurrencesOfString:@"blah" withString:@"blubb"]; prints: escapedFileName: this is a string blubb which replaced blah with blubb, but the backslash is also gone. therefore, this doesn't work either: escapedFileName = [@"this is a string\ blah" stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"]; just strips the backslash, instead of replacing it. NSLog prints: escapedFileName: this is a string blah I'm now wondering what the heck I'm doing wrong here? Any hit with a cluestick is appreciated. Its gnustep-base 1.24.0 I am using. cheers, Sebastian _______________________________________________ Discuss-gnustep mailing list [email protected] https://lists.gnu.org/mailman/listinfo/discuss-gnustep
