bug: wrong encoding when rtf opened in W7

General TRichView support forum. Please post your questions here
Post Reply
Alextp
Posts: 46
Joined: Sun Apr 24, 2011 8:21 am

bug: wrong encoding when rtf opened in W7

Post by Alextp »

open rtf (uvviewsoft.com/beta/) in RVE. XP SP3: opened ok, russian ok. Win7- opened wrong: russian broken.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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
Alextp
Posts: 46
Joined: Sun Apr 24, 2011 8:21 am

Post 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?
Alextp
Posts: 46
Joined: Sun Apr 24, 2011 8:21 am

Post by Alextp »

2) def charset on Win7: russian. Rus Win7. Why is it went wrong?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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.
Alextp
Posts: 46
Joined: Sun Apr 24, 2011 8:21 am

Post by Alextp »

There are several language settings in Windows.
Lang for non-Unicode programs is russian. It is fully rus system.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I cannot reproduce it :(
Does changing UnicodeMode fix the problem?
Alextp
Posts: 46
Joined: Sun Apr 24, 2011 8:21 am

Post by Alextp »

i post demo- www.uvviewsoft.com/beta/RV.rar . Open w7.rtf - Win7 has broken encoding.
Alextp
Posts: 46
Joined: Sun Apr 24, 2011 8:21 am

Post by Alextp »

UnicodeMode = ...OnlyUnicode fixes it. But pls see demo
Post Reply