So I have this file encoded in UTF8. I load it and print like this:
char buffer[2048] = {0};
FILE *pFile = fopen("D:/localization.csv","rb");
int iret = fread(buffer,1,2048,pFile);
fclose(pFile);
wxString strMessageText = wxString::FromUTF8(buffer);
wxMessageBox(strMessageText);
The problem is that when the text contains some "invalid" characters, it doesn't get created (length of strMessageText is 0). I noticed, for instance, that Danish or German characters are fine but when I put Polish or Russian chars in the text file the wxString::FromUTF8 function fails to create proper text. Any idea?
If the file contains correctly encoded UTF-8 text,
wxString::FromUTF8()
will decode it. If it doesn't, you can still use wxMBConvUTF8 with e.g.MAP_INVALID_UTF8_TO_OCTAL
to preserve even incorrectly encoded bytes in the input, but this isn't a good idea, in general.