wxInputStream::GetC() problem in unicode

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Sickboy
Experienced Solver
Experienced Solver
Posts: 91
Joined: Wed Mar 16, 2005 10:30 pm
Location: Germany

wxInputStream::GetC() problem in unicode

Post by Sickboy »

Hi,

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;
}
Any idea what is wrong ?

Thx in advance,
Stefan
Post Reply