Re: [xml] libxml vs stl





--- Jim <jimdon gmail com> wrote:

Hi,

Just a simple question.

When dealing with inputs from libxml i would like to use a stl string
like class ... 

Is this a good idea?

Is there a class that supports wide strings in C++ stl?


I wrote the attached wrapper.  It more or less is an STL string with most of
the conventions but works directly on utf-8 encoded string (stored as a
std::basic_string<unsigned char>.  It has the nice benefit of handling
assignments to std::wstring, which is assumed to be a uTF-16LE string (as is
the case on windows for std::wstring).

It has two iterator types.  The standard iterator/const_iterator returns a
unsigned char* type (as you can't assume *iterator contains a whole character)
and new iterators byte_iterator/const-byte_iterator for going across the
*bytes* that make up a UTF-8 string.

It was inspired by Glib::ustring except that had a ton of Glib specifics, which
I believe is the same as what is used by the libxml++ bindings.

anyways, it's attached.  use at your own risk.

Attachment: xstring.cpp
Description: 3938719972-xstring.cpp

Attachment: xstring.h
Description: 2145917723-xstring.h



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