Re: [xml] Charset trouble
- From: "Peter Jacobi" <pj walter-graphtek com>
- To: "Abylai Ospan" <aospan netup ru>
- Cc: <xml gnome org>
- Subject: Re: [xml] Charset trouble
- Date: Mon, 20 Oct 2003 09:32:06 +0200
Hi Abylai,
"Abylai Ospan" <aospan netup ru> wrote:
I have problem with charsets again ;-(
I'm add in c++
sub_subtree = xmlNewChild(subtree, NULL,(xmlChar*)
"param_value",(xmlChar*)mstring.c_str());
but following error ocure when mstring in KOI8-R charset:
output conversion failed due to conv error
Bytes: 0xC0 0xE1 0xFB 0xEB
As Daniel already pointed out, you have to convert to UTF-8 yourself.
This is totally independent on the output encoding you specify.
As you are on C++, there is a painless, stylistically pleasant
way to never forget the conversion: Put it in the stdcpp string to
char const* conversions.
I don't know if one of the publicly available libxml C++ does
this already, but I use it myself and I suspect others as
well.
Something along the lines of:
typedef xmlChar const *pxmlChar;
class XmlChar: public string {
static char const runtimecharset [];
public:
XmlChar (string const &s): {
convert (s, runtimecharset, *this, "UTF-8");
}
operator pxmlChar () const {return (pxmlChar) c_string ();}
};
Usage:
sub_subtree = xmlNewChild (subtree, NULL,
XmlChar ("param_value"), XmlChar (mstring)
);
Regards,
Peter Jacobi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]