XMLCh and wchar_t

Discussion in 'C++' started by wolverine, Nov 1, 2006.

  1. wolverine

    wolverine Guest

    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.
    wolverine, Nov 1, 2006
    #1
    1. Advertising

  2. On 31 Oct 2006 23:24:09 -0800, "wolverine" <>
    wrote:
    > 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.


    stringstream is a typedef of basic_stringstream:
    http://www.dinkumware.com/manuals/?manual=compleat&page=sstream.html#basic_stringstream
    It seems that you just need another typedef.

    Best wishes,
    Roland Pibinger
    Roland Pibinger, Nov 1, 2006
    #2
    1. Advertising

  3. wolverine

    wolverine Guest

    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" <>
    > wrote:
    > > 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.

    >
    > stringstream is a typedef of basic_stringstream:
    > http://www.dinkumware.com/manuals/?manual=compleat&page=sstream.html#basic_stringstream
    > It seems that you just need another typedef.
    >
    > Best wishes,
    > Roland Pibinger
    wolverine, Nov 1, 2006
    #3
  4. wolverine

    P.J. Plauger Guest

    "wolverine" <> wrote in message
    news:...

    > 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
    P.J. Plauger, Nov 1, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. C_Vieri
    Replies:
    0
    Views:
    821
    C_Vieri
    Jan 7, 2005
  2. AOyake77

    XMLCh and getNodeName

    AOyake77, Jan 7, 2005, in forum: XML
    Replies:
    0
    Views:
    552
    AOyake77
    Jan 7, 2005
  3. Replies:
    0
    Views:
    4,524
  4. =?ISO-8859-15?Q?R=E9mi_Peyronnet?=

    STL & basic_string<XMLCh> link error

    =?ISO-8859-15?Q?R=E9mi_Peyronnet?=, Feb 16, 2004, in forum: C++
    Replies:
    0
    Views:
    533
    =?ISO-8859-15?Q?R=E9mi_Peyronnet?=
    Feb 16, 2004
  5. Replies:
    3
    Views:
    1,096
    James Kanze
    Aug 15, 2008
Loading...

Share This Page