[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-c-dev
Subject:    Re: How do I use Xerces strings?
From:       "Steven T. Hatton" <hattons () globalsymmetry ! com>
Date:       2006-03-09 6:30:38
Message-ID: 200603090130.38958.hattons () globalsymmetry ! com
[Download RAW message or body]

On Wednesday 08 March 2006 03:30, Lumir Vanek wrote:
> Hi,
>
> in KXMLEditor we have helper class for QString - XMLCh* conversion, look
> at:
>
> http://cvs.sourceforge.net/viewcvs.py/kxmleditor/kxmleditor/part/kxestring.
>h?rev=1.7&view=markup
>
> A am not sure, if this approach is absolutely right, but it works for me.

It looks as though the ucs2() has been depracated in favor of utf16 in Qt4.  
What I've been trying to figure out is what it means that Xerces C++ and 
Linux wchar_t don't get along well.  I wrote the functions below in order to 
find which, if any, characters are not identical.  I left out a few which I 
do not understand, and didn't want to research.  I left the chNEL in even 
though I don't know what it's for.  It is not part of ASCII, and therefore 
not part of the C++ basic character set. All the other XMLCh characters match 
their wchar_t counterparts on my SuSE Linux 10 system.

#ifndef UTFTEST_H
#define UTFTEST_H
#include <iomanip>
#include <iostream>
#include <xercesc/util/XMLUniDefs.hpp>

namespace utf {
  using namespace std;
  struct UtfTest {
    
    static std::ostream& printCh(std::ostream& out
				 , const XMLCh   xch
				 , const char*   xname
				 , const wchar_t wch
				 , const char*   wname) {
      return out
	<<boolalpha
	<<"XMLCh: "<<setw(16)<<xname<<" value: "<<setw(4)<<oct<<unsigned(xch)
	<<" wchar_t: "<<setw(6)<<wname<<" value: "<<setw(4)<<oct<<unsigned(wch)
	<<" identical: "<<(xch==wch)<<"\n";
    }

    static std::ostream& print(std::ostream& out) {
      printCh(out, chNull              , "chNull"         , L'\0', "\0" ); 
      printCh(out, chHTab              , "chHTab"         , L'\t', "\\t");
      printCh(out, chLF                , "chLF"           , L'\n', "\\n");
      printCh(out, chVTab              , "chVTab"         , L'\v', "\\v");
      printCh(out, chFF                , "chFF"           , L'\f', "\\f");
      printCh(out, chCR                , "chCR"           , L'\r', "\\r");
      printCh(out, chAmpersand         , "chAmpersand"    , L'\&', "\\&");
      printCh(out, chAsterisk          , "chAsterisk"     , L'\*', "\\*");
      printCh(out, chAt                , "chAt"           , L'\@', "\\@");
      printCh(out, chBackSlash         , "chBackSlash"    , L'\\', "\\");
      printCh(out, chBang              , "chBang"         , L'\!', "!");
      printCh(out, chCaret             , "chCaret"        , L'\^', "^");
      printCh(out, chCloseAngle        , "chCloseAngle"   , L'\>', ">");
      printCh(out, chCloseCurly        , "chCloseCurly"   , L'\}', "}");
      printCh(out, chCloseParen        , "chCloseParen"   , L'\)', ")");
      printCh(out, chCloseSquare       , "chCloseSquare"  , L'\]', "]");
      printCh(out, chColon             , "chColon"        , L'\:', ":");
      printCh(out, chComma             , "chComma"        , L'\,', ",");
      printCh(out, chDash              , "chDash"         , L'\-', "-");
      printCh(out, chDollarSign        , "chDollarSign"   , L'\$', "$");
      printCh(out, chDoubleQuote       , "chDoubleQuote"  , L'\"', "\"");
      printCh(out, chEqual             , "chEqual"        , L'\=', "=");
      printCh(out, chForwardSlash      , "chForwardSlash" , L'\/', "/");
      printCh(out, chGrave             , "chGrave"        , L'\`', "`");
      printCh(out, chNEL               , "chNEL"          , L'\?', "??");
      printCh(out, chOpenAngle         , "chOpenAngle"    , L'\<', "<");
      printCh(out, chOpenCurly         , "chOpenCurly"    , L'\{', "{");
      printCh(out, chOpenParen         , "chOpenParen"    , L'\(', "(");
      printCh(out, chOpenSquare        , "chOpenSquare"   , L'\[', "[");
      printCh(out, chPercent           , "chPercent"      , L'\%', "%");
      printCh(out, chPeriod            , "chPeriod"       , L'\.', ".");
      printCh(out, chPipe              , "chPipe"         , L'\|', "|");
      printCh(out, chPlus              , "chPlus"         , L'\+', "+");
      printCh(out, chPound             , "chPound"        , L'\#', "#");
      printCh(out, chQuestion          , "chQuestion"     , L'\?', "?");
      printCh(out, chSingleQuote       , "chSingleQuote"  , L'\'', "'");
      printCh(out, chSpace             , "chSpace"        , L'\ ', " ");
      printCh(out, chSemiColon         , "chSemiColon"    , L'\;', ";");
      printCh(out, chTilde             , "chTilde"        , L'\~', "~");
      printCh(out, chUnderscore        , "chUnderscore"   , L'\_', "_");

      printCh(out, chDigit_0, "chDigit_0", L'0', "0");
      printCh(out, chDigit_1, "chDigit_1", L'1', "1");
      printCh(out, chDigit_2, "chDigit_2", L'2', "2");
      printCh(out, chDigit_3, "chDigit_3", L'3', "3");
      printCh(out, chDigit_4, "chDigit_4", L'4', "4");
      printCh(out, chDigit_5, "chDigit_5", L'5', "5");
      printCh(out, chDigit_6, "chDigit_6", L'6', "6");
      printCh(out, chDigit_7, "chDigit_7", L'7', "7");
      printCh(out, chDigit_8, "chDigit_8", L'8', "8");
      printCh(out, chDigit_9, "chDigit_9", L'9', "9");

      printCh(out, chLatin_A, "chLatin_A", L'A', "A");
      printCh(out, chLatin_B, "chLatin_B", L'B', "B");
      printCh(out, chLatin_C, "chLatin_C", L'C', "C");
      printCh(out, chLatin_D, "chLatin_D", L'D', "D");
      printCh(out, chLatin_E, "chLatin_E", L'E', "E");
      printCh(out, chLatin_F, "chLatin_F", L'F', "F");
      printCh(out, chLatin_G, "chLatin_G", L'G', "G");
      printCh(out, chLatin_H, "chLatin_H", L'H', "H");
      printCh(out, chLatin_I, "chLatin_I", L'I', "I");
      printCh(out, chLatin_J, "chLatin_J", L'J', "J");
      printCh(out, chLatin_K, "chLatin_K", L'K', "K");
      printCh(out, chLatin_L, "chLatin_L", L'L', "L");
      printCh(out, chLatin_M, "chLatin_M", L'M', "M");
      printCh(out, chLatin_N, "chLatin_N", L'N', "N");
      printCh(out, chLatin_O, "chLatin_O", L'O', "O");
      printCh(out, chLatin_P, "chLatin_P", L'P', "P");
      printCh(out, chLatin_Q, "chLatin_Q", L'Q', "Q");
      printCh(out, chLatin_R, "chLatin_R", L'R', "R");
      printCh(out, chLatin_S, "chLatin_S", L'S', "S");
      printCh(out, chLatin_T, "chLatin_T", L'T', "T");
      printCh(out, chLatin_U, "chLatin_U", L'U', "U");
      printCh(out, chLatin_V, "chLatin_V", L'V', "V");
      printCh(out, chLatin_W, "chLatin_W", L'W', "W");
      printCh(out, chLatin_X, "chLatin_X", L'X', "X");
      printCh(out, chLatin_Y, "chLatin_Y", L'Y', "Y");
      printCh(out, chLatin_Z, "chLatin_Z", L'Z', "Z");

      printCh(out, chLatin_a, "chLatin_a", L'a', "a");
      printCh(out, chLatin_b, "chLatin_b", L'b', "b");
      printCh(out, chLatin_c, "chLatin_c", L'c', "c");
      printCh(out, chLatin_d, "chLatin_d", L'd', "d");
      printCh(out, chLatin_e, "chLatin_e", L'e', "e");
      printCh(out, chLatin_f, "chLatin_f", L'f', "f");
      printCh(out, chLatin_g, "chLatin_g", L'g', "g");
      printCh(out, chLatin_h, "chLatin_h", L'h', "h");
      printCh(out, chLatin_i, "chLatin_i", L'i', "i");
      printCh(out, chLatin_j, "chLatin_j", L'j', "j");
      printCh(out, chLatin_k, "chLatin_k", L'k', "k");
      printCh(out, chLatin_l, "chLatin_l", L'l', "l");
      printCh(out, chLatin_m, "chLatin_m", L'm', "m");
      printCh(out, chLatin_n, "chLatin_n", L'n', "n");
      printCh(out, chLatin_o, "chLatin_o", L'o', "o");
      printCh(out, chLatin_p, "chLatin_p", L'p', "p");
      printCh(out, chLatin_q, "chLatin_q", L'q', "q");
      printCh(out, chLatin_r, "chLatin_r", L'r', "r");
      printCh(out, chLatin_s, "chLatin_s", L's', "s");
      printCh(out, chLatin_t, "chLatin_t", L't', "t");
      printCh(out, chLatin_u, "chLatin_u", L'u', "u");
      printCh(out, chLatin_v, "chLatin_v", L'v', "v");
      printCh(out, chLatin_w, "chLatin_w", L'w', "w");
      printCh(out, chLatin_x, "chLatin_x", L'x', "x");
      printCh(out, chLatin_y, "chLatin_y", L'y', "y");
      printCh(out, chLatin_z, "chLatin_z", L'z', "z");
      out<<noboolalpha;
      return out<<std::endl;

    }
  };

}

#endif

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic