I am trying to pass some simple html to Mail.app: lists, bold, italics. However, I noticed that if I use characters like £ , then Mail.app just doesn't show anything. I realized that I needed to convert to HTML objects like £ (full list here: http://www.w3schools.com/tags/ref_entities.asp ). I have a partial solution that works for most of the characters that my users have come up with, but this is far from a solid fix:
- (NSString*) makeValidHTML:(NSString*)str { str = [str stringByReplacingOccurrencesOfString:@"£" withString:@"£"]; str = [str stringByReplacingOccurrencesOfString:@"¢" withString:@"¢"]; str = [str stringByReplacingOccurrencesOfString:@"¥" withString:@"¥"]; str = [str stringByReplacingOccurrencesOfString:@"©" withString:@"©"]; str = [str stringByReplacingOccurrencesOfString:@"®" withString:@"®"]; str = [str stringByReplacingOccurrencesOfString:@"°" withString:@"°"]; str = [str stringByReplacingOccurrencesOfString:@"¿" withString:@"¿"]; str = [str stringByReplacingOccurrencesOfString:@"¡" withString:@"¡"]; str = [str stringByReplacingOccurrencesOfString:@"'" withString:@"'"]; str = [str stringByReplacingOccurrencesOfString:@"'" withString:@"'"]; str = [str stringByReplacingOccurrencesOfString:@"&" withString:@"&"]; str = [str stringByReplacingOccurrencesOfString:@"\"" withString:@"""]; str = [str stringByReplacingOccurrencesOfString:@""" withString:@"""]; str = [str stringByReplacingOccurrencesOfString:@"<" withString:@"<"]; str = [str stringByReplacingOccurrencesOfString:@">" withString:@">"]; return str; }
Is there a standard way to do this without having to list all possible reserved characters?
source share