Re: [xml] Question about using SHIFT-JIS encoding with libxml2



On Thu, Apr 12, 2007 at 02:39:44PM +0530, Agarwal, Saumya wrote:
Hi,
 
I am using libxml2 for xml parsing. When the client application sends
data to libxml2 in UTF-8 format, it works fine.
 
But, I have a scenarion in which the client application sends data to
libxml2 parser in SHIFT-JIS format.  
 
I have added the encoding declaration to the XML as follows  -
<?xml version="1.0" encoding="SHIFT-JIS"?> 

  That should be suficient.
By using a recent api like xmlReadxxx you can also provide the encoding
when starting the parser without modifying the document

The following error is thrown by libxml2 -
 
"Parsing error in results: Input is not proper UTF-8, indicate encoding
! " 

  Either the declaration was not read, or the converter failed to 
convert it to UTF-8. My guess would be that the first is the most likely.

In libxml2 documentation at http://www.xmlsoft.org/encoding.html
<http://www.xmlsoft.org/encoding.html> , I read that libxml2 can support
any encoding by calling the xmlSwitchEncoding() routine.
What do I have to do to make libxml2 support SHIFT-JIS format? I want to
continue supporting UTF-8 also.

  That should not be needed assumimg you use the library with iconv support
and that your version of iconv support SHIFT-JIS (it should really).

Daniel

-- 
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine  http://rpmfind.net/



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