Here's what I have been using.
$trans= array("'" => "'", "'" => "'",">" => ">", "<" => "<", "&" => "&","-" => "-", "°" => "°", "±" => "±", "-" => "–", """ => "“", """ => "”","..." => "…","'" => "‘","²" =>"²","·" => "·" ); $value=strtr($value,$trans); Luis -----Original Message----- From: David Otton [mailto:[EMAIL PROTECTED] Sent: Monday, August 04, 2003 7:18 AM To: Russell P Jones Cc: [EMAIL PROTECTED] Subject: Re: [PHP] Invalid Characters, XML... On Sun, 3 Aug 2003 21:51:53 -0400 (EDT), you wrote: >Im using PHP to write to XML files, but I am having some problems. A lot >of users are cutting and pasting content from text editors like word, >which uses odd quotation marks, dashes, etc. which PHP writes to the XML >file, and then the XML parser does not under stand. Is there a >stripslashes() or htmlspecialchars() equivalent that will convert this >kind of stuff to the correct ascii text? This should get you started. It behaves as does htmlentities(). For those high-ASCII characters out of Word/IE... decide what regular ASCII character you want to map them to, (eg slanted-quote-open and -close to regular quote), and add them to the $trans array before performing the array_walk(). function xmlentities ($string, $quote_style = ENT_COMPAT) { static $trans; if (!is_array ($trans)) { $trans = get_html_translation_table (HTML_ENTITIES, $quote_style); array_walk ($trans, create_function ('&$a, $b', '$a = "&#" . ord ($b) . ";";')); } return (strtr ($string, $trans)); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php