[libxml++] Also Have Problems with UTF-8 in Example Code: 'Glib::ConvertError'



It seems I am having the same issue (or very similar) someone had back in 2008: http://sourceforge.net/mailarchive/forum.php?thread_name=481EEFF6.5020002%40balabit.hu&forum_name=libxmlplusplus-general


1) copied the DOM parser code from the "short manual" (http://libxmlplusplus.sourceforge.net/docs/manual/html/ar01s02.html#id2504579)
2) compiled it without problem
3) ran it on a simple "example.xml" file. 

It crashes with 'Glib::ConvertError'. Removing the UTF-8 characters fixes the problem, but obviously that's not a great solution. Also, if I do not attempt to 'cout' the field with UTF-8 characters, it also does not crash, but I need to output the field.

The example output is as follows:
~~~~~~~~~~~~~~~~~
Node name = note
Node name = note
     line = 10

  Node name = to
Node name = to
       line = 11

    Text Node
    text = "Joe"

  Node name = from
Node name = from
       line = 12

    Text Node
    text = "Jany"

  Node name = heading
Node name = heading
       line = 13

    Text Node
    text = "Reminder

  Node name = body
Node name = body
       line = 14

    Text Node
terminate called after throwing an instance of 'Glib::ConvertError'
    Abort trap: 6 (core dumped)

~~~~~~~~~~~~~~~~~
$ cat example.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note [
<!ELEMENT note    (to,from,heading,body)>
<!ELEMENT to      (#PCDATA)>
<!ELEMENT from    (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body    (#PCDATA)>
]>
<note>
   <to>Joe</to>
   <from>Jany</from>
   <heading>Reminder</heading>
<body>ÐÑивеÑ! Don't forget me this weekend!</body>
</note>
~~~~~~~~~~~~~~~~~~~

I'm running freeBSD 8.0:
$ uname -a
FreeBSD selever 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:02:08 UTC 2009     root mason cse buffalo edu:/usr/obj/usr/src/sys/GENERIC  amd64

In general, is it rather difficult to output UTF-8 (requiring special environments)? Any help, tips, or advice would be most appreciated.




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