Converting & to & in Objective-C [duplicate]
I have a URL string in the following format.
http://myserver.com/_layouts/feed.aspx?xsl=4&web=%2F&page=dda3fd10-c776-4d69-8c55-2f1c74b343e2&wp=476f174a-82df-4611-a3df-e13255d97533
I want to replace &
with &
in the above URL. My result should be:
http://myserver.com/_layouts/feed.aspx?xsl=4&web=%2F&page=dda3fd10-c776-4d69-8c55-2f1c74b343e2&wp=476f174a-82df-4611-a3df-e13255d97533
Can someone post me the code to get this done?
Thanks
Solution 1:
Check out my NSString category for HTML. Here are the methods available:
// Strips HTML tags & comments, removes extra whitespace and decodes HTML character entities.
- (NSString *)stringByConvertingHTMLToPlainText;
// Decode all HTML entities using GTM.
- (NSString *)stringByDecodingHTMLEntities;
// Encode all HTML entities using GTM.
- (NSString *)stringByEncodingHTMLEntities;
// Minimal unicode encoding will only cover characters from table
// A.2.2 of http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters
// which is what you want for a unicode encoded webpage.
- (NSString *)stringByEncodingHTMLEntities:(BOOL)isUnicode;
// Replace newlines with <br /> tags.
- (NSString *)stringWithNewLinesAsBRs;
// Remove newlines and white space from string.
- (NSString *)stringByRemovingNewLinesAndWhitespace;
Solution 2:
[urlString stringByReplacingOccurrencesOfString:@"&" withString:@"&"];