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

On Thu, Apr 12, 2007 at 02:39:44PM +0530, Agarwal, Saumya wrote:
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
<> , 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).


Red Hat Virtualization group
Daniel Veillard      | virtualization library
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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