Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Mar 2007 12:58:08 +0400
From:      "Andrew Pantyukhin" <infofarmer@FreeBSD.org>
To:        "Alexander Nedotsukov" <bland@freebsd.org>
Cc:        freebsd-gnome@freebsd.org
Subject:   Re: Need a suggest the best way to fix iconv..
Message-ID:  <cb5206420703290158r5c5c0465l7f2587967db87f58@mail.gmail.com>
In-Reply-To: <45C7F45D.4020407@FreeBSD.org>
References:  <op.tnaf1tni9aq2h7@mezz.mezzweb.com> <45C7F45D.4020407@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2/6/07, Alexander Nedotsukov <bland@freebsd.org> wrote:
> Jeremy Messenger wrote:
> > Hello folks,
> >
> > I am not sure what is the best way to fix iconv. I get following build
> > error:
> >
> > ===================================
> > client/Text.cpp: In static member function `static std::string&
> > Text::convert(const std::string&, std::string&, const std::string&,
> > const std::string&)':
> > client/Text.cpp:312: error: invalid conversion from `char**' to `const
> > char**'
> > client/Text.cpp:312: error:   initializing argument 2 of `size_t
> > libiconv(void*, const char**, size_t*, char**, size_t*)'
> > ===================================
> >
> > The code looks like (last line is 312 line):
> >
> > ===================================
> >     size_t rv;
> >     size_t len = str.length() * 2; // optimization
> >     size_t inleft = str.length();
> >     size_t outleft = len;
> >     tmp.resize(len);
> >     const char *inbuf = str.data();
> >     char *outbuf = (char *)tmp.data();
> >
> >     while(inleft > 0) {
> >         rv = iconv(cd, (char **)&inbuf, &inleft, &outbuf, &outleft);
> > ===================================
> >
> > Which should I change it to?
> >
> > rv = iconv(cd, (const char **)&inbuf, &inleft, &outbuf, &outleft);
> >
> > or
> >
> > rv = iconv(cd, &inbuf, &inleft, &outbuf, &outleft);
> This one. And if you have a plan to send your patch back to the authors
> it is better to declare inbuf as ICONV_CONST char* as well (though not
> sure if their configure smart enough to define that macro. check
> produced config.h to be sure).

This iconv issue appears every now and again. I'm sorry
to bother you guys, but any suggestions how to fix this
one are welcome:

==================================================
        size_t inSize;
        char *in;
        if (myBuffer.empty()) {
                inSize = srcEnd - srcStart;
                in = (char*)srcStart;
        } else {
                myBuffer.append(srcStart, srcEnd - srcStart);
                inSize = myBuffer.length();
                in = (char*)myBuffer.data();
        }

        size_t outSize = 3 * inSize;
        const size_t startOutSize = outSize;
        size_t oldLength = dst.length();
        dst.append(outSize, '\0');
        char *out = (char*)dst.data() + oldLength;

iconvlabel:
        iconv(myIConverter, &in, &inSize, &out, &outSize);
==================================================

Should I add another const and initialize with "in"?

Thanks!



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?cb5206420703290158r5c5c0465l7f2587967db87f58>