file:read-text
Tuesday, 12 January 2021 · 4 messages
GC
Giuseppe G. A. Celano12 Jan 2021 13:33 #
Hi,
I am trying to open a bunch of files with
file:read-text, but I get the error [file:io-error] invalid XML character: #0, even I am not dealing with XML. Any idea why this happens? Thanks!
Best,
GiuseppeMH
Martin Honnen12 Jan 2021 13:41 #
Quoted text · Giuseppe G. A. Celano · 8 lines
On 12.01.2021 13:33, Giuseppe G. A. Celano wrote: > Hi, > > I am trying to open a bunch of files with file:read-text, but I get > the error [file:io-error] invalid XML character: #0, even I am not > dealing with XML. Any idea why this happens? Thanks! > >
Perhaps as XQuery strings impose XML rules for allowed characters? Can you read out the files as binary hex or base64?
GC
Giuseppe G. A. Celano12 Jan 2021 13:50 #
I have found that a few files are not txt, but binary ones. I can open them with
file:read-binary. However, the reference to XML can be confusing because I am not dealing with XML.Quoted text · Martin Honnen · 11 lines
> On 12. Jan 2021, at 13:41, Martin Honnen <martin.honnen at gmx.de> wrote: > > > > On 12.01.2021 13:33, Giuseppe G. A. Celano wrote: >> Hi, >> >> I am trying to open a bunch of files with file:read-text <file:///read-text>, but I get the error [file:io-error <file:///io-error>] invalid XML character: #0, even I am not dealing with XML. Any idea why this happens? Thanks! >> >> > Perhaps as XQuery strings impose XML rules for allowed characters? Can you read out the files as binary hex or base64?
MH
Martin Honnen12 Jan 2021 13:59 #
Quoted text · Giuseppe G. A. Celano · 4 lines
On 12.01.2021 13:50, Giuseppe G. A. Celano wrote: > I have found that a few files are not txt, but binary ones. I can open > them with file:read-binary. However, the reference to XML can be > confusing because I am not dealing with XML.
I think https://docs.basex.org/wiki/File_Module#file:read-text suggests you can use
file:read-text("file.txt", "UTF-8", true)and you won't get the error about invalid characters, instead the returned string contains the Unicode replacement character|FFFD|
Quoted text · Giuseppe G. A. Celano · 18 lines
> > > >> On 12. Jan 2021, at 13:41, Martin Honnen <martin.honnen at gmx.de >> <mailto:martin.honnen at gmx.de>> wrote: >> >> >> On 12.01.2021 13:33, Giuseppe G. A. Celano wrote: >>> Hi, >>> >>> I am trying to open a bunch of files with file:read-text, but I get >>> the error [file:io-error] invalid XML character: #0, even I am not >>> dealing with XML. Any idea why this happens? Thanks! >>> >>> >> Perhaps as XQuery strings impose XML rules for allowed characters? >> Can you read out the files as binary hex or base64? >
Written for BaseX 9.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery