-    // file should be opened and we must be in it's beginning
-    wxASSERT( m_file.IsOpened() &&
-                (m_file.GetKind() != wxFILE_KIND_DISK || m_file.Tell() == 0) );
+    // file should be opened
+    wxASSERT_MSG( m_file.IsOpened(), _T("can't read closed file") );
+
+    // read the entire file in memory: this is not the most efficient thing to
+    // do it but there is no good way to avoid it in Unicode build because if
+    // we read the file block by block we can't convert each block to Unicode
+    // separately (the last multibyte char in the block might be only partially
+    // read and so the conversion would fail) and, as the file contents is kept
+    // in memory by wxTextFile anyhow, it shouldn't be a big problem to read
+    // the file entirely
+    size_t bufSize = 0;
+
+    // number of bytes to (try to) read from disk at once
+    static const size_t BLOCK_SIZE = 4096;
+
+    wxCharBuffer buf;
+
+    // first determine if the file is seekable or not and so whether we can
+    // determine its length in advance
+    wxFileOffset fileLength;
+    {
+        wxLogNull logNull;
+        fileLength = m_file.Length();
+    }