List Info

Thread: Question about using SHIFT-JIS encoding with libxml2




Question about using SHIFT-JIS encoding with libxml2
user name
2007-04-12 04:09:44
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"?> ;
 
The following error is thrown by libxml2 -
 
"Parsing error in results: Input is not proper UTF-8, indicate encoding ! " 
 
In libxml2 documentation at http://www.xmlsoft.org/encoding.htmlI 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.
 
 
Thanks,
Saumya
Re: Question about using SHIFT-JIS encoding with libxml2
user name
2007-04-12 07:10:20
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.xmlso
ft.org/encoding.html
> <http://www.x
mlsoft.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/v
irtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
veillardredhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ |
Rpmfind RPM search engine  http://rpmfind.net/
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )