Re: [libxml++] std::string as a container for UTF-8 data in libxml++



Tim Conkling wrote:
I'm one of the (many?) libxml++ 2.0 users who's using std::string in place of glib::ustring as a container for text. For various reasons outside of my control, I am not able to link to glib::ustring, but I do occasionally need to get non-ASCII Unicode data out of XML documents. Am I correct in believing that libxml++ will correctly store UTF-8 data in a std::string, such that I can later access the contents of a std::string's character buffer directly and the UTF-8 data will still be intact, or does std::string somehow mangle or reject non-ASCII characters?

As I haven't looked at libxml++ for quite some time I'm not qualified to
comment on that part. However, I can confirm that std::string is happy
to accept UTF-8 data. 's.size()' will give you the numbers of bytes in s,
not characters, then, and strlen(s.data()) will still work, too
(though, again, returning number of bytes, not characters), since both
ASCII as well as UTF-8 are NULL-terminated.

Regards,
		Stefan






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