Multiple spaces lost when saving to HTML

General TRichView support forum. Please post your questions here
Post Reply
sage12
Posts: 2
Joined: Tue Sep 11, 2018 9:55 am

Multiple spaces lost when saving to HTML

Post by sage12 » Tue Oct 02, 2018 4:13 am

Hello,

I was testing TRichView and trying to Save the RichViewEdit to HTML with the following code:

Stream1:=TStringStream.Create('');
RichViewEdit1.SaveHTMLToStreamEx(
Stream1,'','Test','','','','', [rvsoUseCheckpointsNames,rvsoNoHypertextImageBorders,rvsoMarkersAsText]);

After I do, the text: "Test_________Test_____________Test"
is converted to: "Test Test Test"

( the "_" character should be considered as space character )

how can this be resolved?

Thanks.
Last edited by sage12 on Tue Oct 02, 2018 6:45 am, edited 1 time in total.

Sergey Tkachenko
Site Admin
Posts: 14119
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Multiple spaces lost when saving to HTML

Post by Sergey Tkachenko » Tue Oct 02, 2018 6:02 am

This is a bug.
Quick fix: open RVStrFuncs.pas, change the following functions:

Code: Select all

function RV_ReplaceStrA(const Str, oldstr, newstr: TRVAnsiString): TRVAnsiString;
var
  p, LastIndex: Integer;
begin
  Result := Str;
  p := RVStrLow();
  LastIndex := RVStrHighA(Result);
  while p <= LastIndex do
  begin
    p := RVPosExA(oldstr, Result, p);
    if p = RVStrNoIndex() then
      break;
    RVDeleteA(Result, p, Length(oldstr));
    RVInsertA(newstr, Result, p);
    inc(p, Length(newstr));
    LastIndex := RVStrHighA(Result);
  end;
end;
{------------------------------------------------------------------------------}
function RV_ReplaceStrW(const Str, oldstr, newstr: TRVUnicodeString): TRVUnicodeString;
var
  p, LastIndex: Integer;
begin
  Result := Str;
  p := RVStrLow();
  LastIndex := RVStrHighW(Result);
  while p <= LastIndex do
  begin
    p := RVPosExW(oldstr, Result, p);
    if p = RVStrNoIndex() then
      break;
    RVDeleteW(Result, p, Length(oldstr));
    RVInsertW(newstr, Result, p);
    inc(p, Length(newstr));
    LastIndex := RVStrHighW(Result);
  end;
end;

Post Reply