note 59485 added to function.utf8-decode

From: Date: Thu, 08 Dec 2005 08:04:39 +0000
Subject: note 59485 added to function.utf8-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-99731@lists.php.net to get a copy of this message
I've just created this code snippet to improve the user-customizable emails sent by one of my websites. The goal was to use UTF-8 (Unicode) so that non-english users have all the Unicode benefits, BUT also make life seamless for English (or specifically, English MS-Outlook users). The niggle: Outlook prior to 2003 (?) does not properly detect unicode emails. When "smart quotes" from MS Word were pasted into a rich text area and saved in Unicode, then sent by email to an Outlook user, more often than not, these characters were wrongly rendered as "greek". So, the following code snippet replaces a few strategic characters into html entities which Outlook XP (and possibly earlier) will render as expected. [Code based on bits of code from previous posts on this and the htmlenties page] <?php $badwordchars=array( "\xe2\x80\x98", // left single quote "\xe2\x80\x99", // right single quote "\xe2\x80\x9c", // left double quote "\xe2\x80\x9d", // right double quote "\xe2\x80\x94", // em dash "\xe2\x80\xa6" // elipses ); $fixedwordchars=array( "&#8216;", "&#8217;", '&#8220;', '&#8221;', '&mdash;', '&#8230;' ); $html=str_replace($badwordchars,$fixedwordchars,$html); ?> ---- Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59485 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59485&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59485&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59485&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59485&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59485&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59485&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59485&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59485&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#99731) next »