note 63783 added to function.str-replace
| From: | mattwheaton at osu1 dot php dot net | Date: | Thu, 30 Mar 2006 15:40:40 +0000 |
| Subject: | note 63783 added to function.str-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-107037@lists.php.net to get a copy of this message | ||
As an effort to remove those Word copy and paste smart quotes, I've found that this works with
UTF8 encoded strings (where $text in the following example is UTF8). Also the elipsis and em and en
dashes are replaced.
There is an "invisible" character after the â⬠for the right side double smart
quote that doesn't seem to display here. It is chr(157).
<?php
$find[] = 'ââ¬Å'; // left side double smart quote
$find[] = 'ââ¬Â'; // right side double smart quote
$find[] = 'ââ¬Ë'; // left side single smart quote
$find[] = 'ââ¬â¢'; // right side single smart quote
$find[] = 'ââ¬Â¦'; // elipsis
$find[] = 'ââ¬â'; // em dash
$find[] = 'ââ¬â'; // en dash
$replace[] = '"';
$replace[] = '"';
$replace[] = "'";
$replace[] = "'";
$replace[] = "...";
$replace[] = "-";
$replace[] = "-";
$text = str_replace($find, $replace, $text);
?>
----
Server IP: 216.235.15.211
Probable Submitter: 204.187.63.106 (proxied: 1.0 PORTIA)
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.str-replace.php
Edit -- http://master.php.net/note/edit/63783
Del: integrated -- http://master.php.net/note/delete/63783/integrated
Del: useless -- http://master.php.net/note/delete/63783/useless
Del: bad code -- http://master.php.net/note/delete/63783/bad+code
Del: spam -- http://master.php.net/note/delete/63783/spam
Del: non-english -- http://master.php.net/note/delete/63783/non-english
Del: in docs -- http://master.php.net/note/delete/63783/in+docs
Del: other reasons-- http://master.php.net/note/delete/63783
Reject -- http://master.php.net/note/reject/63783
Search -- http://master.php.net/manage/user-notes.php