views:

59

answers:

2

I have parsed some data from webpage content and stored it as an NSString. In that string there is a unicode character (\u0097). How can i remove or replace this and avoid all unicode characters?

I tried using this line but it hasn't worked:

[webpagecontent stringByReplacingOccurrencesOfString:@"\\u0097" withString:@" "];

Can anyone help me?

Thanks in advance.........

A: 

Sadly, there is no escape sequence that is legal C (\u0097 is not) and works in GCC. You'll have to use stringWithFormat: or stringWithCharacters:.

Peter Hosey
A: 

If you want to "avoid all unicode characters" you could probably make an NSCharacterSet that contains everything except ASCII characters (you would want -[NSCharacterSet characterSetWithRange:]), then use -[NSString rangeOfCharacterFromSet:] and -[NSMutableString deleteCharactersInRange:] to remove the characters.

Tom Dalling