Hi,

I'm trying to create a mailto: link in a page that will fill in the Subject and Bopy of a new email message with Spanish-language text. The text lives in strings in an array of localized text. Accented characters in the text are encoded as HTML entities. So, for example, the subject and body text might look like this in the raw data:

  $subject = 'Art&iculo acerca de Spyware';
  $body = 'Creo que te será de interés este artíulo...';

I can't figure out how to URL encode the characters so they work properly when the email link is created. I tried:

  $encSubject = rawurlencode(html_entity_decode($subject));
  $encBody = rawurlencode(html_entity_decode($body));

  echo '<a href="mailto:?subject=' . $encSubject . "&body=" . $encBody . (etc.)

but that didn't work. The accented characters show up as empty squares in the email.

I also tried adding various charset parameters to html_entity_decode, but that didn't work either:

  $encSubject = rawurlencode(html_entity_decode($subject), ISO-8859-1);

What does appear to work is simply not encoding the text at all, but that leaves a bunch of spaces and ampersand characters in the URL, and that's not supposed to be done.

I'd appreciate the list's help figuring out how to do this. Many thanks!

-Jim

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to