C程序编码转换GBK转UTF-8

我想问一下,我c程序编码是gbk的,但是我接收的信息是utf-8的,我要把这串信息丢到数据库里,数据库也是utf-8的,我怎么样把我的程序编码转换成utf-8呢

std::string AnsiToUTF8(const char *szAnsi)
{
            WCHAR*     strA;
            int   i = MultiByteToWideChar(CP_ACP, 0, szAnsi, -1, NULL, 0);
            strA = new  WCHAR[i];
            MultiByteToWideChar(CP_ACP, 0, szAnsi, -1, strA, i);

            i = WideCharToMultiByte(CP_UTF8, 0, strA, -1, NULL, 0, NULL, NULL);
            char *strB = new char[i];
            WideCharToMultiByte(CP_UTF8, 0, strA, -1, strB, i, NULL, NULL);

            string utf8(strB, i - 1);

            delete[]strA;
            delete[]strB;

            return utf8;
}

用setParameters