char *pszAnsi;
while (czytaj(file, &pszAnsi))
{
int ansiLen = strlen(pszAnsi);
int UnicodeLen = (ansiLen*2)+1;
WCHAR *pszUnicode = new WCHAR[UnicodeLen];
// ansi -> unicode
MultiByteToWideChar(CP_ACP, 0, pszAnsi, -1, pszUnicode, UnicodeLen);
// unicode -> utf8
// ** liczba znaków może być większa nawet od ansiLen*2
// więc pytamy o rozmiar bufora (uwzględia końcowe NULL)
int utf8Len = WideCharToMultiByte(CP_UTF8, 0, pszUnicode, -1, 0, 0, 0, 0);
// if (!utf8Len) error();
char *pszUtf8 = new char[utf8Len];
WideCharToMultiByte(CP_UTF8, 0, pszUnicode, -1, pszUtf8, utf8Len, 0, 0);
delete pszUnicode;
zapisz(file, pszUtf8, utf8Len-1); // -1: bez końcowego NULL
delete pszUtf8;
}