In my app it accepts XML from the server. One of its functions returns a list of names, some having apostrophes (e.g. O’Reilly ).
<?xml version="1.0" encoding="UTF-8" ?>
<user id="123456" name="Pat O\'Reilly" is_qualified="false" />
In my parser I try two different methods to get rid of the escape slash, but neither of them work:
[[attributeDict valueForKey:@"name"] stringByReplacingOccurrencesOfString:@"\'" withString:@"'"]
and/or
[[attributeDict valueForKey:@"name"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
Printing these out both include the slash: Pat O\’Reilly. any suggestions?
What you want to replace is
@"\\\'"with@"\'"Both
\and'are special characters.You might even need to replace
@"\\\""with@"\""for other texts that look likeblaname="bla is \"bla\" and bla".