Re: [libxml++] program crashes when parsing XML with accent



Christophe de Vienne wrote:

Christophe de VIENNE wrote:

Murray Cumming wrote:

Rather than getting the number of characters and then giving that to the ustring constructor to convert back to number of bytes, I suggest we put
the string in a std::string and just use the Glib::ustring(std::string)
constructor. I can't see a more suitable ustring constructor.

Indeed (cf my other message).
However I think we should signal this to the glibmm dev team, so they at least document it since it does not have the behavior we naturaly though it had.

Fixed in the CVS.
However before releasing 2.6.1 I want to be 100% sure that the sax callbacks characters and cdata_block gives zero terminated strings.


Well, I had a look to libxml2 source and it seems that the character callback may be called with a non zero-terminated string.
The solution is, I think, to instanciate like this :
Glib::ustring( std::string(ch, len) )
This should not make unecessary buffer copy with g++ 3.x at least, since std::string has a COW implementation, and Glib::ustring constructor taking a std::string just copy it.
Are we ok with this ?

Christophe




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