[xsd-users] Problem with parsing xml documents containing Chinese
characters
Feng Tony
fengtr at gmail.com
Tue Mar 2 23:01:00 EST 2010
Thank you, Boris!
In my last reply, the last question is I wonder if a name can be assigned to
a const char* type as:
const char * pChar = name;
it's convenient, isn't it? May be one can implement it by creating a
subclass of name, but I hadn't tried it yet.
My project can solve my problem right now.
Thank you very much!
On Fri, Feb 26, 2010 at 11:25 PM, Boris Kolpackov
<boris at codesynthesis.com>wrote:
> Hi Tony,
>
> In the future please keep your replies CC'ed to the xsd-users mailing
> list as discussed in the posting guidelines:
>
> http://www.codesynthesis.com/support/posting-guidelines.xhtml
>
> Feng Tony <fengtr at gmail.com> writes:
>
> > Hi Boris,
> > Thanks for your excellent work.The xsd-3.3.0.b2-i686-windows version
> works
> > fine with wchar_t option.
>
> Glad to hear that.
>
>
> > But I still have some questions:
> > 1. "In this case Chinese characters will be encoded in UTF-8."
> > Did you mean that the Chinese characters will be encoded in UTF-8 when I
> > used MBCS character set in my project?
>
> That's correct. The character encoding used in the object model is
> independent of the operating system code page (except for one case,
> see below).
>
>
> > Then if I want to assign the string to variables of char* type and
> display
> > them in screen,how can I do it perfectly?
>
> There are several ways to do this.
>
> 1. You can use WideCharToMultiByte/MultiByteToWideChar with CP_UTF8
> to manually convert between UTF-8 and the current code page (this
> is Windows-specific).
>
> 2. You can try to use the Xerces-C++ "local code page" encoding for
> the object model. Chances are everything will work out of the box
> automatically.
>
> To do this, I suggest that you download XSD 3.3.0.b1 (see the
> download page[1]) and pass '--char-encoding lcp' option when
> compiling your schemas. Then you should be able to simply do:
>
> const char* s = foo->name ().c_str ();
>
>
> > 2.What is the correct method to extract a name or a desc string and
> assign
> > it to a string instance or a char* variable?
> > Is the following code correct?
> > if (it->desc().present())
> > {
> > tc.InsertItem(it->desc().get().c_str(), m_hIED);
> > }
>
> Yes, looks about right, if you are using the second (lcp) approach.
>
> > I thank if there is one overload member function like this(pseudo code):
> > tDescType & operator=( const TCHAR* ) {}
> > then it will be perfect, doesn't it? :)
>
> I am not sure I understand this part. Where do you expect such an operator
> to be define?
>
> [1] http://www.codesynthesis.com/products/xsd/download.xhtml
>
> Boris
>
> >
> > I am sorry for my poor expressions!
> >
> > Best regards
> >
> > Tony
>
More information about the xsd-users
mailing list