creating mailto: URL including 8-bit characters

From: Date: Thu, 24 Aug 2006 15:56:51 +0000
Subject: creating mailto: URL including 8-bit characters
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-241087@lists.php.net to get a copy of this message
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&aacute; de inter&eacute;s este art&iacute;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

« previous php.general (#241087) next »