Page 1 of 1

bug: wrong encoding when rtf opened in W7

Posted: Sat Apr 30, 2011 7:24 am
by Alextp
open rtf (uvviewsoft.com/beta/) in RVE. XP SP3: opened ok, russian ok. Win7- opened wrong: russian broken.

Posted: Sat Apr 30, 2011 10:25 am
by Sergey Tkachenko
The main problem with this RTF file: it does not specify that the text is Russian. It has the following font table:

Code: Select all

{\fonttbl{\f0 \froman Times New Roman;}{\f1 \fscript \fcharset0 Monotype Corsiva;}{\f2 \froman \fcharset2 Symbol;}{\f3 \froman \fcharset0 Times New Roman;}{\f4 \froman \fcharset0 Arial;}{\f5 \froman Arial;}{\f6 \froman Wingdings;}}
You can see only 3 fonts with defined charset: f1 and f4 with charset=0 (ANSI_CHARSET) and f2 with charset=2 (SYMBOL_CHARSET). Charsets for other fonts is undefined, so TRichView uses DEFAULT_CHARSET, and the result depends on the system default language (defined in the Control Panel).

On the other side, the text in this file is Unicode, so, if it is loaded as Unicode, charset is not so important. However, it cab be read correctly (without conversion from Unicode to ANSI) only if RV.RTFReadProperties = rvruOnlyUnicode

Posted: Sat Apr 30, 2011 1:19 pm
by Alextp
However, it cab be read correctly only if RV.RTFReadProperties = rvruOnlyUnicode
if i set so, won't it be wrong for non-Unicode rtfs? Can Unicode rtf always read as unicode?

Posted: Sat Apr 30, 2011 1:20 pm
by Alextp
2) def charset on Win7: russian. Rus Win7. Why is it went wrong?

Posted: Sat Apr 30, 2011 6:24 pm
by Sergey Tkachenko
There are several language settings in Windows. The one that important is in the last tab of Regional and language settings, it is called Language for non-Unicode programs (or something like this).

But once again, the problem is in the RTF file itself. It does not specify that the text is Russian, so non-Unicode applications can read it differently.

As for RV.RTFReadProperties = rvruOnlyUnicode, it works correctly both for Unicode and non-Unicode RTF (when reading, non-Unicode text will be converted to Unicode). This is the default option for TRichView in Delphi 2009, 2010 and XE.

Posted: Sat Apr 30, 2011 6:41 pm
by Alextp
There are several language settings in Windows.
Lang for non-Unicode programs is russian. It is fully rus system.

Posted: Sun May 01, 2011 9:00 am
by Sergey Tkachenko
I cannot reproduce it :(
Does changing UnicodeMode fix the problem?

Posted: Sun May 01, 2011 9:47 am
by Alextp
i post demo- www.uvviewsoft.com/beta/RV.rar . Open w7.rtf - Win7 has broken encoding.

Posted: Mon May 02, 2011 10:35 am
by Alextp
UnicodeMode = ...OnlyUnicode fixes it. But pls see demo