[xml] Read&Write Files with unicode/UTF-16 names (on Windows) (was: RE: Read tree from FILE* ?)



I wrote:
Any Windows users out there who'd share (some example code) 
how they get around the windows-filenames issue?


Well, after looking at xmlReadIO(..) and also looking at
xmlRegisterInputCallbacks(..) I've decided to skip all that and just use
xmlReadMemory(..) and xmlDocDumpFormatMemoryEnc(..) and read/write the files
myself to a character buffer.
This works OK, since I'm only using the tree API at the moment.

Still, allow me to phrase two questions:
* Is there an opposite to xmlReadIO, something like xmlWriteIO ?
* Is anyone using the xmlRegisterInputCallbacks(..) to open files with wide
character names? (It seems to me this would require some additional
wrapping, since the callback functions get char* for the file URL. So I'd
first had to encode the wchar_t filename to utf8 and the, in the callback,
decode it again.)


best regards / mit freundlichen Grüßen,
Martin Trappel


-----Original Message-----
From: Trappel Martin [mailto:martin trappel ksengineers at] 
Sent: Monday, April 23, 2007 9:17 AM
To: veillard redhat com
Cc: xml gnome org
Subject: Re: [xml] Read tree from FILE* ?

-----Original Message-----
From: Daniel Veillard [mailto:veillard redhat com]
Sent: Sunday, April 22, 2007 9:56 PM
To: Trappel Martin
Cc: xml gnome org
Subject: Re: [xml] Read tree from FILE* ?

On Fri, Apr 20, 2007 at 11:32:18AM +0200, Trappel Martin wrote:
Hello!

I successfully can use xmlDocFormatDump(FILE*, xmlDocPtr,
int) to save
my xml document tree to a file.

However, I seem unable to find out how to _read_ a document
tree from
a FILE*.
Is there an opposite funtion to xmlDocDump?

(The reason why I want to use FILE* is that I'm on windows and 
therefore my filenames are UTF-16 which I can't give to 
libxml. If 
there is another solution to this problem than via 
opening the file 
myself I would also take that one. :)

  And if your program and libxml2 happen to have been compiled with 
even slightly different flags, the library and your program will 
expect different version of FILE * structure and this will 
crash and 
burn. This is such a problem that basically I avoid this in API.
  You can certainly create what you need based on
    http://xmlsoft.org/html/libxml-parser.html#xmlReadIO


Thanks for the pointer. Will certainly look into this.
(And, yes, already had a crach with FILE* ... That's why I recompiled
libxml2 to use the same lib as our app ... But you're 
probablby right when you say one is better of not depending 
on this api :)


Any Windows users out there who'd share (some example code) 
how they get around the windows-filenames issue?


Cheers,
Martin
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/ 
xml gnome org http://mail.gnome.org/mailman/listinfo/xml




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