Ask a Question related to PHP Development, Design and Development.
-
Luis Lebron #1
RE: [PHP] Invalid Characters, XML...
Here's what I have been using.
$trans= array("'" => "'", "'" => "'",">" => ">", "<" => "<",
"&" => "&","-" => "-", "°" => "°", "±" => "±", "-" =>
"", """ => "", """ => "","..." => "…","'" =>
"‘","²" =>"²","·" => "·" );
$value=strtr($value,$trans);
Luis
-----Original Message-----
From: David Otton [mailto:phpmail@jawbone.freeserve.co.uk]
Sent: Monday, August 04, 2003 7:18 AM
To: Russell P Jones
Cc: [email]php-general@lists.php.net[/email]
Subject: Re: [PHP] Invalid Characters, XML...
On Sun, 3 Aug 2003 21:51:53 -0400 (EDT), you wrote:
This should get you started. It behaves as does htmlentities().>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?
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
Luis Lebron Guest
-
error invalid characters in my cfquery?
The list. What is that datatype your passing the list to? Is it an numeric based or string? If it is a string (char, varchar, ntext, nvarchar,... -
Using Invalid Characters
I am using MS SQL for my ASP application and have several 'comments' fields. Obviously in these fields users are going to enter invalid characters... -
Matching invalid characters in a URL
I'm trying to throw out URLs with any invalid characters in them, like '@". According to http://www.ietf.org/rfc/rfc1738.txt : Thus, only... -
#25405 [Opn->Bgs]: The session id contains invalid characters
ID: 25405 Updated by: iliaa@php.net Reported By: pop501 at hotmail dot com -Status: Open +Status: ... -
Invalid Characters, XML...
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,... -
Ivo Pletikosic #2
RE: [PHP] Invalid Characters, XML...
I had a similar problem recently, but was not able to work with it in PHP
tho. The array for that mapped characters to their entity turned out to be
HUGE and it took forever to evaluate long XML files.
I ended up killing several birds with one stone by wrapping the html-tidy
utility (tidy.sourceforge.net) in php. It validates xml, converts all
characters >127 into their respective entity, pretties up the XML output,
cleans up Word 2000 specific content and deals with a variety of
input/output encodings. It did all these a lot faster that any of the
scripts I had written and saved me from writing others.
-----Original Message-----
From: Russell P Jones [mailto:rjones@email.unc.edu]
Sent: Sunday, August 03, 2003 6:52 PM
To: [email]php-general@lists.php.net[/email]
Subject: [PHP] Invalid Characters, XML...
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?
Russ
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Ivo Pletikosic Guest



Reply With Quote

