note 102465 added to function.str-replace

From: Date: Wed, 16 Feb 2011 15:16:34 +0000
Subject: note 102465 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-177035@lists.php.net to get a copy of this message
This strips out horrible MS word characters. Just keep fine tuning it until you get what you need, you'll see ive commented some out which caused problems for me. There could be some that need adding in, but its a start to anyone who wishes to make their own custom function. <?php function msword_conversion($str) { $str = str_replace(chr(130), ',', $str); // baseline single quote $str = str_replace(chr(131), 'NLG', $str); // florin $str = str_replace(chr(132), '"', $str); // baseline double quote $str = str_replace(chr(133), '...', $str); // ellipsis $str = str_replace(chr(134), '**', $str); // dagger (a second footnote) $str = str_replace(chr(135), '***', $str); // double dagger (a third footnote) $str = str_replace(chr(136), '^', $str); // circumflex accent $str = str_replace(chr(137), 'o/oo', $str); // permile $str = str_replace(chr(138), 'Sh', $str); // S Hacek $str = str_replace(chr(139), '<', $str); // left single guillemet // $str = str_replace(chr(140), 'OE', $str); // OE ligature $str = str_replace(chr(145), "'", $str); // left single quote $str = str_replace(chr(146), "'", $str); // right single quote // $str = str_replace(chr(147), '"', $str); // left double quote // $str = str_replace(chr(148), '"', $str); // right double quote $str = str_replace(chr(149), '-', $str); // bullet $str = str_replace(chr(150), '-–', $str); // endash $str = str_replace(chr(151), '--', $str); // emdash // $str = str_replace(chr(152), '~', $str); // tilde accent // $str = str_replace(chr(153), '(TM)', $str); // trademark ligature $str = str_replace(chr(154), 'sh', $str); // s Hacek $str = str_replace(chr(155), '>', $str); // right single guillemet // $str = str_replace(chr(156), 'oe', $str); // oe ligature $str = str_replace(chr(159), 'Y', $str); // Y Dieresis $str = str_replace('°C', '&deg;C', $str); // Celcius is used quite a lot so it makes sense to add this in $str = str_replace('£', '&pound;', $str); $str = str_replace("'", "'", $str); $str = str_replace('"', '"', $str); $str = str_replace('–', '&ndash;', $str); return $str; } ?> ---- Server IP: 87.124.126.135 Probable Submitter: 195.149.3.163 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/102465 Del: integrated -- https://master.php.net/note/delete/102465/integrated Del: useless -- https://master.php.net/note/delete/102465/useless Del: bad code -- https://master.php.net/note/delete/102465/bad+code Del: spam -- https://master.php.net/note/delete/102465/spam Del: non-english -- https://master.php.net/note/delete/102465/non-english Del: in docs -- https://master.php.net/note/delete/102465/in+docs Del: other reasons-- https://master.php.net/note/delete/102465 Reject -- https://master.php.net/note/reject/102465 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177035) next »