[xml] UTF8ToHtml Umlaut bug?

I wanna use http://xmlsoft.org/html/libxml-HTMLparser.html#UTF8ToHtml
and I have the following code:

#include <stdio.h>
#include <string.h>
#include <libxml/HTMLparser.h>

#define BUFSIZE 1024

int main()
        char buf[BUFSIZE];
        char *txt = "<>{}'Ãblabla";
        int inlen, txt_len;
        inlen = txt_len = strlen(txt);
        int outlen;
        int outdone = 0, indone = 0;

        int ret;

        printf("before: %s\n", txt);

                outlen = 100;
                inlen = txt_len - indone; printf("intxt: %s inlen:
%d\n", txt+indone, inlen);
                ret = UTF8ToHtml((xmlChar*)buf, &outlen,
(xmlChar*)txt+indone, &inlen);
                indone += inlen;
                outdone += outlen;
                printf("converted: %.*s (%d)\n", outlen, buf, outlen);

        } while(indone != txt_len);


this works as normal, buf if you replace "outlen = 100;" with "outlen
= 4;" it hangs at converting the umlaut
(means outlen is set to zero after UTF8ToHtml).
Moreover, why isn't it converting '<' to '&lt;'?
thx for your answer

P.S.: is there a htmlwriter in libxml2? I've only seen a xmlwriter.

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