我在 AIX 上使用 c++/XMS 来使用来自 MQ 的传入消息。现在我需要将消息从 ISO8859-1 转换为 UTF-8。我执行以下操作。
==================================================== ====
void iso2utf8( char* text_iso, char* text_utf8, int nLen)
{
cout << "Converting to UTF-8." << endl;
iconv_t ic;
ic = iconv_open("UTF-8", "ISO8859-1"); // iso->utf8
cout << "Size of text_iso" << sizeof(text_iso) << endl;
size_t il = nLen;
size_t ol = nLen;
cout << "Size of text_iso" << ol << endl;
iconv(ic , &text_iso, &il, &text_utf8, &ol);
iconv_close(ic);
cout << "Message in UTF-8: " << text_utf8 << endl;
return;
}
==================================================== ====
转换后,当我将消息保存到文件中时,我会返回 ISO8859-1 消息。有关如何解决此问题的任何提示。我使用 fstream 写入文件。