View Issue Details

IDProjectCategoryView StatusLast Update
0004632JEDI VCL00 JVCL Componentspublic2012-09-10 14:15
ReportercabAssigned Toobones 
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.35 
Target VersionFixed in Version3.46 
Summary0004632: jvDBRichEdit shows rtf code instead of formatted text
DescriptionWhen the component is showing its contents it looks like this:

I am typing the following text:
This a test - testing error.

and when approving it (write to database it looks like this:
{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Riched20 12.0.6211.1000;}\viewkind4\uc1
\pard\cf1\f0\fs16\lang1030 This a test - testing error.\par
}
Additional InformationI am using delphi 2009, on Vista Business SP1.
Have tried Riched20.dll from both Windows and Office 2003
TagsNo tags attached.

Relationships

has duplicate 0004571 resolvedobones JvRichEdit 

Activities

cab

2008-12-21 12:44

reporter   ~0015122

Just tried Delphi7 with jvcl 3.33 - and this combination works OK.
Apparently the problem are due toimplementation of unicode in the Delphi2009 version of the jvcl?

cab

2008-12-21 14:45

reporter   ~0015124

This is the same issue as 0004571.
And I have traced the error down to the following function:

function TJvRTFConversion.IsFormatCorrect(AStream: TStream): Boolean;
const
  CRTFHeader = '{\rtf';
  CRTFHeaderSize = Length(CRTFHeader);
var
  SavedPosition: Int64;
  Buffer: array[0..CRTFHeaderSize] of Char; // + #0
begin
  SavedPosition := AStream.Position;
  try
    Buffer[CRTFHeaderSize] := #0;

    Result :=
      (AStream.Read(Buffer, CRTFHeaderSize) = CRTFHeaderSize) and
      (StrIComp(PChar(CRTFHeader), Buffer) = 0);
  finally
    AStream.Position := SavedPosition;
  end;
end;

the AStream.Read reads unicode in delphi 2009, so the compare with CRTFHeader (= '{\rtf') will not match the read unicode characters, which are: ('?', '?', '?', '?', '?', #0).

If I change this to the following it works, but I'm not sure if this is the correct way of doing it:
function TJvRTFConversion.IsFormatCorrect(AStream: TStream): Boolean;
const
  CRTFHeader = '{\rtf';
  CRTFHeaderSize = Length(CRTFHeader);
var
  SavedPosition: Int64;
  Buffer: array[0..CRTFHeaderSize] of ansiChar; // + #0
begin
  SavedPosition := AStream.Position;
  try
    Buffer[CRTFHeaderSize] := #0;

    Result :=
      (AStream.Read(Buffer, CRTFHeaderSize) = CRTFHeaderSize) and
      (StrIComp(PansiChar(CRTFHeader), Buffer) = 0);
  finally
    AStream.Position := SavedPosition;
  end;
end;

obones

2008-12-22 04:16

administrator   ~0015125

Thanks, it does look interesting.
Pending further investigation on the source of the Stream

obones

2012-02-27 14:01

administrator   ~0019581

This was fixed back in March 2009:

ahuser 21/03/2009 23:18:25
Unicode bugfixes

Issue History

Date Modified Username Field Change
2008-12-21 09:44 cab New Issue
2008-12-21 12:44 cab Note Added: 0015122
2008-12-21 14:45 cab Note Added: 0015124
2008-12-22 04:15 obones Relationship added related to 0004571
2008-12-22 04:16 obones Note Added: 0015125
2008-12-22 04:16 obones Status new => acknowledged
2009-04-29 15:36 obones Relationship replaced has duplicate 0004571
2012-02-27 14:01 obones Note Added: 0019581
2012-02-27 14:01 obones Status acknowledged => resolved
2012-02-27 14:01 obones Fixed in Version => Daily / SVN
2012-02-27 14:01 obones Resolution open => fixed
2012-02-27 14:01 obones Assigned To => obones
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46