By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,655 Members | 964 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,655 IT Pros & Developers. It's quick & easy.

XMLCh and wchar_t

P: n/a
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_traitsuString; 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.

Nov 1 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On 31 Oct 2006 23:24:09 -0800, "wolverine" <ki*********@gmail.com>
wrote:
Then i tried creating a new string class like typedef
std::basic_string<XMLCh, XMLCh_traitsuString; 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.
stringstream is a typedef of basic_stringstream:
http://www.dinkumware.com/manuals/?m...c_stringstream
It seems that you just need another typedef.

Best wishes,
Roland Pibinger
Nov 1 '06 #2

P: n/a
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.

Roland Pibinger wrote:
On 31 Oct 2006 23:24:09 -0800, "wolverine" <ki*********@gmail.com>
wrote:
Then i tried creating a new string class like typedef
std::basic_string<XMLCh, XMLCh_traitsuString; 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.

stringstream is a typedef of basic_stringstream:
http://www.dinkumware.com/manuals/?m...c_stringstream
It seems that you just need another typedef.

Best wishes,
Roland Pibinger
Nov 1 '06 #3

P: n/a
"wolverine" <ki*********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
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 shortthat probably do what you
want with no need to define additional superstructure.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Nov 1 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.