libiconv - cannot convert argument 2 from 'char **' to 'const char **'

288 Views Asked by At

I am trying to use libxml2 with libiconv to parse xml files. Now I faced encoding conversion issue.

here is my function:

char* convert_iconv(char* in)
{
    char* out;
    size_t size, out_size;

    size = strlen(in) + 1;
    out_size = size * 2 - 1;
    out = (char*)malloc(out_size);

    iconv_t ic = iconv_open("WINDOWS-1251", "UTF-8");
    iconv(ic, &in, &size, &out, &out_size);
    iconv_close(ic);

    
    return (out);
}

function iconv(ic, &in, &size, &out, &out_size) gives an error:

cannot convert argument 2 from 'char **' to 'const char **'

okay, that function really needs const char **

//size_t iconv(iconv_t cd, const char** inbuf, size_t * inbytesleft, char** outbuf, size_t * outbytesleft);

But any attempts to pass const char ** as an argument fail. First error still occurs, and another error appears:

argument of type "const char **" is incompatible with parameter of type "char **"

Changing

char* convert_iconv(char* in)

to

char* convert_iconv(const char* in)

doesn't help

Can you please tell me what I am doing wrong?

0

There are 0 best solutions below