xerces and UTF-16 encoding

Discussion in 'XML' started by stil, Jul 26, 2006.

  1. stil

    stil Guest

    hi,

    i've got a little problem with encoding in UTF_16.
    i create my document, giving him to my writer to write in a string,
    when i set an encoding in UTF-8:

    DOMWriter* L_poWriter = L_poImplementation->createDOMWriter();
    XMLCh* L_poEncoding = XMLString::transcode( "UTF-8" );
    L_poWriter->setEncoding(L_poEncoding);

    and then write and get the result:

    L_poWriter->writeNode(L_poTarget, *P_poNode);

    // WARNING
    // using reinterpret cast because the other cast didn't work:
    // one day, it's will explode
    P_rsResult =
    string(
    reinterpret_cast<const char*>(
    L_poTarget->getRawBuffer()
    )
    );

    the resulting string is valid and contains my Xml.
    when i do the same except i encode in UTF-16 the resulting string is
    empty

    is use xerces v.2.4.0-1.7.0
    if you have any idea of what append ?

    thanks in advance.
    stil
    stil, Jul 26, 2006
    #1
    1. Advertising

  2. On 26 Jul 2006, stil wrote:

    > Organization: http://groups.google.com
    >
    > i've got a little problem with encoding in UTF_16.


    You are funny! You are posting over Google's Usenet interface
    and Google itself cannot read UTF-16. Most hits from
    http://www.google.com/search?q="UTF 1 6"
    are webpages encoded in UTF-16, but not recognized by Google.
    Go to the "Cached" versions!

    Why do you want UTF-16 in the first place? UTF-16 and UTF-32
    are no good for markup languages with ASCII markup.
    UTF-8 is much better suited for XML and HTML.
    http://ppewww.ph.gla.ac.uk/~flavell/charset/checklist.html
    Andreas Prilop, Jul 26, 2006
    #2
    1. Advertising

  3. In article <>,
    stil <> wrote:

    >the resulting string is valid and contains my Xml.
    >when i do the same except i encode in UTF-16 the resulting string is
    >empty


    I'm not a C++ programmer, but are you using a char * string to store
    your UTF-16 result? If so, it will probably look empty (or just have
    one character) because each character will occupy two chars and either
    the first of second char will be zero.

    -- Richard
    Richard Tobin, Jul 26, 2006
    #3
  4. stil

    stil Guest

    you're correct, when i check the resulting raw buffer, it contains the
    value but the translation into a string lost the result as the first
    character is a \0.

    stil

    ps: i'm going to try a wstring, i hope it will be better ;)

    Richard Tobin a écrit :

    > In article <>,
    > stil <> wrote:
    >
    > >the resulting string is valid and contains my Xml.
    > >when i do the same except i encode in UTF-16 the resulting string is
    > >empty

    >
    > I'm not a C++ programmer, but are you using a char * string to store
    > your UTF-16 result? If so, it will probably look empty (or just have
    > one character) because each character will occupy two chars and either
    > the first of second char will be zero.
    >
    > -- Richard
    stil, Jul 26, 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. mel-tey chamon!
    Replies:
    2
    Views:
    1,352
    Patrick TJ McPhee
    May 16, 2004
  2. cvissy
    Replies:
    0
    Views:
    592
    cvissy
    Nov 16, 2004
  3. Shyamrox
    Replies:
    2
    Views:
    2,924
    Shyamrox
    May 25, 2006
  4. Replies:
    2
    Views:
    347
  5. Replies:
    2
    Views:
    360
    Nathan Keel
    Aug 14, 2009
Loading...

Share This Page