SOLVED => is ' or " different in MS-Word then ascII?

From: Date: Fri, 16 Jan 2004 15:47:39 +0000
Subject: SOLVED => is ' or " different in MS-Word then ascII?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-174832@lists.php.net to get a copy of this message
Here is a real code solution instead of my original posted client solution.... My original problem involved text submitted via the good old fashion <textarea> in a web form. If a visitor created their text in MS-Word and then cut and paste their text over to the web form and submitted, any place within their text that they used ' or " would be turned into little white boxes. After spending a day researching this problem, I realized I could just inform the visitors to turn off Smart Quotes in their word processor application. Overcome with frustration and exhaustion, I posted this to the list as SOLVED and provided my client solution. As many of you pointed out (thank you), it's not a valid solution for a large user base. And as some pointed out (thank you), it's not a solution by any means... Tom Rogers explained the problem and provided a code solution: The problem is that Microsoft uses a non standard Latin-1 code for their "smart" quotes and a lot of programs don't know what to do with them as a few are actually control codes in other languages. <?php function clean_ms_word($text){ $crap = array( chr(0x82),chr(0x83),chr(0x84),chr(0x85),chr(0x86),chr(0x87),chr(0x88),chr(0x89), chr(0x8a),chr(0x8b),chr(0x8c),chr(0x91),chr(0x92),chr(0x93),chr(0x94),chr(0x95), chr(0x96),chr(0x97),chr(0x98),chr(0x99),chr(0x9a),chr(0x9b),chr(0x9c),chr(0x9f)
        );
$clean = array( '&lsquor;','&fnof;','&ldquor;','&ldots;','&dagger;','&Dagger;','','&permil;', '&Scaron;','&lsaquo;','&OElig;','&lsquo;','&rsquo;','&ldquo;','&rdquo;','&bull;', '&ndash;','&mdash;','&tilde;','&trade;','&scaron;','&rsaquo;','&oelig;','&Yuml;'
        );
$content = str_replace($crap,$clean,$text); return $content; } $string = chr(0x93).'Test'.chr(0x94); echo clean_ms_word($string).'<br>'; Thanks Tom! Works like a charm!! Also, thanks to everyone who offered tips, suggestions, and solutions... R

« previous php.general (#174832) next »