[PHP] DOM - Question about \0

2008-03-16 Thread dav
Hi,

I have question about \0 character with DOM :

?php
$cdata = 'foo' . \0 . 'bar';

$dom = new DOMDocument('1.0', 'utf-8');
$dom-formatOutput = true;

$container = $dom-createElement('root');
$blob = $dom-createElement('blob');

$blob-appendChild($dom-createCDATASection($cdata));

$container-appendChild($blob);
$dom-appendChild($container);

echo 'pre' . htmlentities($dom-saveXML());

/*
Result :

?xml version=1.0 encoding=utf-8?
root
  blob![CDATA[foo]]/blob
/root
*/
?


What to do with the character \0 ? encode this character to obtain : 
![CDATA[foo00;bar]] ? or skip the character with str_replace(\0, '', 
$cdata)  ?

What is the best thing to do ? i like to conserve the \0 because is a blob data

Jabber is how to transmit binary ?


Sorry for by bad english.


Thank you.

--
Free pop3 email with a spam filter.
http://www.bluebottle.com/tag/5


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



Re: [PHP] DOM - Question about \0

2008-03-16 Thread Casey
On Sun, Mar 16, 2008 at 1:50 AM, dav [EMAIL PROTECTED] wrote:
 Hi,

  I have question about \0 character with DOM :

  ?php
  $cdata = 'foo' . \0 . 'bar';

  $dom = new DOMDocument('1.0', 'utf-8');
  $dom-formatOutput = true;

  $container = $dom-createElement('root');
 $blob = $dom-createElement('blob');

 $blob-appendChild($dom-createCDATASection($cdata));

 $container-appendChild($blob);
  $dom-appendChild($container);

  echo 'pre' . htmlentities($dom-saveXML());

  /*
  Result :

  ?xml version=1.0 encoding=utf-8?
  root
   blob![CDATA[foo]]/blob
  /root
  */
  ?


  What to do with the character \0 ? encode this character to obtain : 
 ![CDATA[foo00;bar]] ? or skip the character with str_replace(\0, '', 
 $cdata)  ?

  What is the best thing to do ? i like to conserve the \0 because is a blob 
 data

  Jabber is how to transmit binary ?


  Sorry for by bad english.


  Thank you.

  --
  Free pop3 email with a spam filter.
  http://www.bluebottle.com/tag/5


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



Maybe the entity #00; works?

-- 
-Casey

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