Please tell me what I am doing wrong:

#include <libxml/encoding.h>
#include <wchar.h>

int main()
{
xmlCharEncodingHandlerPtr utf16Enc = xmlFindCharEncodingHandler("UTF-16");
 wchar_t* url = L"http://atest.com";;
xmlBufferPtr in = xmlBufferCreateStatic(url, wcslen(url) * 2);
 xmlBufferPtr out = xmlBufferCreate();

int rc = xmlCharEncInFunc(utf16Enc, out, in);
 printf("rc=%d url=%s\n", rc, (char*)out->content);

xmlBufferFree(in);
 xmlBufferFree(out);

return 0;
}

on Windows with version libxml2-2.7.7 I get:
rc=16 url=http://atest.com

on i386 Debian with version libxml2-2.7.8 I get:
rc=16 url=h

It looks like on Debian that it has simply copied the input buffer into the
output buffer:
url[0] = 'h'
url[1] = '\0'
url[2] = 't'
...


Thanks.
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml

Reply via email to