[xml] isoLat1toUTF8 conv error



Hi list,

Still on my encodings problems, in fact, I want to translate a const char* named "texte" which contains a text encoded in iso-latin-1 ( iso-8859-1 exactly ) to UTF8, because of the libxml2 api wants it.

So I use isolat1ToUTF8 :


   unsigned char* texte_tmp = NULL;
   int outlen=0, inlen = strlen(texte);

// I allocate twice the size of texte to be sure enough memory will be allocated for the result texte_tmp = (unsigned char *) malloc ( sizeof ( unsigned char) * strlen(texte)*2);

   // here I go
   isolat1ToUTF8(texte_tmp, &outlen, ( const unsigned char*)texte, &inlen);
   tmp = xmlNewText( BAD_CAST texte_tmp );

But I encounter some problem, especially this one :

output conversion failed due to conv error
Bytes: 0x83 0x09 0x09 0x3C
I/O error : encoder error

I don't understand why, and if I change this line :

   tmp = xmlNewText( BAD_CAST texte_tmp );

by this one :

   tmp = xmlNewText( BAD_CAST "texte_tmp" );

everything is ok and "texte_tmp" is well inserted. But of, course, I don't care about "texte_tmp", I just want to obtain the
text contained in texte_tmp.

Regards;

--
_____________________________________________
Remy HAREL          -        Teamlog        |
____________________________________________|
Linux registered user #224740               |
France Telecom Recherche & Developpement    |
____________________________________________| __________________@ http://www.chezrem.org @|





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]