Re: HTMLEntities as NUMERIC for XML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





ceo@xxxxxxxxx wrote:
After reading this:
http://validator.w3.org/feed/docs/error/UndefinedNamedEntity.html
(all praise W3.org!)

I am searching for a PHP library function that will convert all my &abc; into {

I have a zillion of these things from converting stupid MS Word characters into something that will, like, you know, actually WORK on the Internet, and do not really want to re-invent the wheel here.

Somebody has to have written this function...

I'm kind of surprised it's not http://php.net/xmlentities or somesuch...


Here's what I use:

//Translate table for dumb Windows chars when user paste from Word; function strips all >160
$win1252ToPlainTextArray=array(
chr(130)=> ',',
chr(131)=> '',
chr(132)=> ',,',
chr(133)=> '...',
chr(134)=> '+',
chr(135)=> '',
chr(139)=> '<',
chr(145)=> '\'',
chr(146)=> '\'',
chr(147)=> '"',
chr(148)=> '"',
chr(149)=> '*',
chr(150)=> '-',
chr(151)=> '-',
chr(155)=> '>',
chr(160)=> ' ',
);


function cleanWin1252Text($str)
{
global $win1252ToPlainTextArray; //translate array for many dumb Windows special chars; used for paste in textarears
    $str = strtr($str, $win1252ToPlainTextArray);
    $str = trim($str);
    $patterns = array('%[\x7F-\x81]%', '%[\x83]%', '%[\x87-\x8A]%', '%[\x8C-\x90]%',  %[\x98-\xff]%');
    return preg_replace($patterns, '', $str); //Strip
}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux