Re: Detecting \u0000 in a string...
| From: | Casey | Date: | Mon, 17 Mar 2008 22:28:40 +0000 |
| Subject: | Re: Detecting \u0000 in a string... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-271697@lists.php.net to get a copy of this message | ||
On Mon, Mar 17, 2008 at 3:56 AM, Mikey <frak@upcore.net> wrote:
> Hi!
>
> I was wondering if anyone here had experienced a simliar problem to mine.
>
> I am updating an Oracle XMLType column with XML built using DOM that is
> populated with values from an Excel spreadsheet saved out as a CSV.
>
> My problem is that for certain (apparently) random rows the xml updated
> will fail with the error:
>
> Warning: oci_execute(): OCIStmtExecute: ORA-31011: XML parsing failed
> ORA-19202: Error occurred in XML processing
> LPX-00217: invalid character 0 (\u0000)
> Error at line 1
> ORA-06512: at "SYS.XMLTYPE", line 5
> ORA-06512: at line 1
> in /path/ob/fu/scated/archive.inc on line 1374
>
> I have googled around and a Java fix for the problem seemed to revolve
> around a null char being left on the end of the XML string, so I tried
> stripping the last char from the string but this did not help. I then
> used an ordUTF8 function I found in the manual notes to see if I could
> find the null in the string - again, no luck.
>
> So my question is whether or not anyone here has a reliable way of
> detcting and removing \u0000 chars from strings?
>
> regards,
>
> Mikey
>
> --
How about:
$str = str_replace("\0", '', $str);
-Casey