when i try to use the following method to read an ASCII formated file the result is an UTF-8 encoded wxString instead of a normal unicode string.
When i use wxTextInputStream::Readline() the string is correctly, but wxTextInputStream is very slow and i have to parse large files (>200mb).
Code: Select all
bool QuickRead(wxInputStream &input)
{
wxChar* txtBuf = txt.GetWriteBuf(80);
short k = 0;
while(stream.IsOk() && !stream.Eof())
{
if (k == 80) // We have 80 characters in a line including \r\n; this is just a quick dirty check
{
txt.UngetWriteBuf(k-1);
return false;
}
else
txtBuf[k] = stream.GetC();
if (txtBuf[k] == wxT('\r') || txtBuf[k] == wxT('\n'))
{
txt.UngetWriteBuf(k);
DoSomething(txt);
k = 0;
txtBuf = txt.GetWriteBuf(80);
}else
k++;
}
return true;
}
Thx in advance,
Stefan