Re: [xml] Target string size after transcoding



On Thu, Sep 24, 2009 at 09:32:51PM -0700, mini thomas wrote:
Thanks . But I mean to ask this.
 
To transcode a string of length 'n' bytes to UTF-8.. I need to allocate  4n bytes and pass it to 
xmlCharEncodingInputFunc.  4n bytes may not be fully used. 
 
Allocating memory is expensive when I need to handle big xml documents. ( Passing input string and a null 
value for target string,  to MultiByteToWideChar() will return the buffer size required to transcode the 
input string  without performing actual transcoding ). Can I do the same with libxml2 API's ?

  No, that takes the same computational time. The APIs are designed
to be used progressivly (convert as needed instead of keeping megabytes
of data sitting around). It's actually the iconv() POSIX APIs mostly
  Rethink your processing way, it's not a good idea to convert huge
amount of data, let them sit around until you've finished processing.
and with current computer arch this is especially inefficient (the cache
is teh key to speed).

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/



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