title: How do I encode "&" in a URL in an HTML attribute value?
body: <p>I'd like to make a URL click able in the email app.  The problem is that a parameterized URL breaks this because of "&amp;" in the URL.  The body variable below is the problem line.  Both versions of "body" are incorrect.  Once the email app opens, text stops at "...link:".  What is needed to encode the ampersand?</p>
  
  <pre><code>NSString *subject = @"This is a test";
  NSString *encodedSubject = 
  [subject stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
  
  //NSString *body = @"This is a link: &lt;a href='http://somewhere.com/two.woa/wa?id=000&amp;param=0'&gt;click me&lt;/a&gt;"; //original
  NSString *body = @"This is a link: &lt;a href='http://somewhere.com/two.woa/wa?id=000&amp;#38;param=0'&gt;click me&lt;/a&gt;"; //have also tried &amp;amp;
  NSString *encodedBody = 
  [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; 
  NSString *formattedURL = [NSString stringWithFormat: @"mailto:myname@somedomain.com?subject=%@&amp;body=%@", encodedSubject, encodedBody];
  NSURL *url = [[NSURL alloc] initWithString:formattedURL];
  [[UIApplication sharedApplication] openURL:url];
  </code></pre>