tags:

views:

416

answers:

7

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
Consider providing an answer, rather than linking to a discussion board where the answer is unclear.
notnoop
A: 

Try this:

NSCharacterSet* badUnicodeCharSet = [NSCharacterSet characterSetWithCharactersInString:@"\u0097"];
theString = [[theString componentsSeparatedByCharactersInSet:badUnicodeCharSet] componentsJoinedByString:@""];
Tom Dalling
+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
A: 

Thanks for your replay...

But i cant use this into my code @"\u0097" its make an error

Error:\u0097 is not a valid character

How can i fix this?

A: 

This link may help: Stripping out a set of characters from an NSString

taber
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
A: 

This method @"\u0097" also not work fine...

Any way thanks for replay