Menu

#560 Unicode builds of the RichEditor example cannot read RTF files.

unspecified
open
nobody
None
1
2023-09-20
2023-09-19
No

When the RichEditor example is built with Unicode, it fails to open RTF files with a message "Document read error".

Even creating a new RTF document and attempting to save it results in this error. Note that the document is saved correctly and can be opened by the non-Unicode version of RichEdit or by WordPad.

Discussion

  • Ognyan Chernokozhev

    The problem tested as present in OWLNext 6.44 as well, and possibly in older versions too.

    Possibly the conditional UNICODE code in the callback method RichEditStrmInWithIStream is not correct. It has been changed in OWLNext's Dark Ages - [r30] - which corresponds roughly to the OWLNext 6.20 release.

     

    Related

    Commit: [r30]

  • Ognyan Chernokozhev

    Reverting the RichEditStrmInWithIStream code to basically it's pre-[r30] version seems to resolve the issue.

    My guess is that SF_RTF files are never in Unicode, regardless of whether they were saved by a Unicode or single-byte application, and thus the attempt to read a Unicode string from the input stream and then use WideCharToMultiByte coversion is wrong.

     

    Related

    Commit: [r30]

    • Ognyan Chernokozhev

      Ok, reverting the code to use something like
      is.read(reinterpret_cast<TCHAR*>(pbBuff), cb);
      works only in some cases.

      In others, most likely due to attempting to read from the input buffer and convert to Unicode characters, there is garbage inserted in the buffer.

      And the whole DocView architecture does not make it easy to switch to use ifstream instead of wifstream for Unicode builds.

       

Log in to post a comment.