XMLCh and wchar_t

W

wolverine

Hi
Let me explain my situation first. I was porting a code from
windows to linux. The code used xerces parser and also used
std::wstring thoughout. When i came to linux the XMLCh(typedef
unsigned short) is of 2 bytes and wchar_t is 4 bytes. So it became
impossible to use std::wstring in the code as it was also using xerces
which expects each character (XMLCh) as 2 bytes.

Then i tried creating a new string class like typedef
std::basic_string<XMLCh, XMLCh_traits> uString; with traits defined.
Then came the new problem, i also needed to create stringstream for the
above defined uString. This is going from tough to tougher.

Have any one of you encountered the same problem or the appropriate
question is to ask a solution for the problem rather than creating
uString and uStringStream.

Thanks in Advance
Kiran.
 
R

Roland Pibinger

W

wolverine

Hi,
Thanks for the reply. It is not as easy as it seems to be. I need
to use operators like << and >>. This was the reply i got from one of
the guys in the group.

Bo Persson says :: "The string_stream does not only depend on
char_traits, but also on locale info implemented for your characetr
type. In this case operator>> (unsigned
short&) is looking for a std::ctype<XMLCh>, which isn't
available.Fixing the std::locale for a new char type is really, really
hard to do.:-( "

Regards
Kiran.
 
P

P.J. Plauger

Thanks for the reply. It is not as easy as it seems to be. I need
to use operators like << and >>. This was the reply i got from one of
the guys in the group.

Bo Persson says :: "The string_stream does not only depend on
char_traits, but also on locale info implemented for your characetr
type. In this case operator>> (unsigned
short&) is looking for a std::ctype<XMLCh>, which isn't
available.Fixing the std::locale for a new char type is really, really
hard to do.:-( "

Basically true, but our library makes up these facets as needed,
and mostly guesses right. You can create a basic_string<unsigned short>
and a basic_ostringstream<unsigned short> that probably do what you
want with no need to define additional superstructure.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,999
Messages
2,570,243
Members
46,838
Latest member
KandiceChi

Latest Threads

Top