I want to strip a Unicode character (\u0097) from NSString....
A:
I'm assuming that you're trying to strip the character from an NSString. I did a quick google search and found this link.
I hope this helps.
Alex Morales
2009-07-09 13:28:41
Consider providing an answer, rather than linking to a discussion board where the answer is unclear.
notnoop
2009-07-09 14:16:14
A:
Try this:
NSCharacterSet* badUnicodeCharSet = [NSCharacterSet characterSetWithCharactersInString:@"\u0097"];
theString = [[theString componentsSeparatedByCharactersInSet:badUnicodeCharSet] componentsJoinedByString:@""];
Tom Dalling
2009-07-09 13:39:13
+2
A:
This is simplest to remove \u0097:
NSString * deGremlinedString = [theString stringByReplacingOccurrencesOfString:@"\u0097" withString:@""];
The docs for that method are right here.
Alternatively, if the starting string is an NSMutableString, then you can use this method:
[theMutableString replaceOccurrencesOfString:@"\u0097" withString:@"" options:NSLiteralSearch range:NSMakeRange(0, [theMutableString length])];
Dave DeLong
2009-07-09 14:48:10
A:
I believe you have to use two backslashes to escape the backslash. So @"\\u0097"
. I'm not positive, but I read this page that says:
the reason for that is the first backslash is an escape in the string literal (so you can do things like @"\""); the second backslash is the one that makes it into the string to be parsed by NSConstantString. --boredzo
Sorry if this is wrong, but it was what I understood from the page.
Jorge Israel Peña
2009-07-10 04:29:59