Upon paste html, strange characters in TRichEdit

General TRichView support forum. Please post your questions here
Post Reply
techmon
Posts: 4
Joined: Fri Apr 11, 2014 2:46 am

Upon paste html, strange characters in TRichEdit

Post by techmon »

Good Day,

When I copy html from a web browser, and paste the html from clipboard into TRichEdit, I sometimes get strange characters like this between words:

 Â      Â

Please advise

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

Post by Sergey Tkachenko »

How to reproduce it?
techmon
Posts: 4
Joined: Fri Apr 11, 2014 2:46 am

Post by techmon »

use a web browser like firefox and go to to a site...like https://www.google.com/intl/en/about/

and copy some text from there to your windows clipboard

then paste it into TRichEdit

here is HTML conversion procedure that we use to convert HTML to RVE format

procedure HTMLToRichView( HTML : string; PRichEdit : TRichViewEdit );
var
HTMLViewer: THTMLViewer;
Importer: TRVHTMLViewImporter;
p1 : integer;
begin
PRichEdit.Clear;
if HTML <> '' then begin
p1 := Pos( '<head>', HTML ); //
if ( p1 > 0 ) and ( ( Pos( '<meta name=Generator content="Microsoft Word', HTML ) > p1 )
or ( Pos( '<meta name="viewport"', HTML ) > p1 ) )then
begin
//fix of Microsoft word distorted html
HTML := HtmlCutHead( HTML );
end;
HTMLViewer := THTMLViewer.Create(nil);
HTMLViewer.Visible := False;
HTMLViewer.Parent := PRichEdit.Parent;
HTMLViewer.DefBackground := clWhite;
Importer := TRVHTMLViewImporter.Create(nil);
try
HTMLViewer.LoadFromString( HTML );
Importer.ImportHtmlViewer( HTMLViewer, PRichEdit );
finally
Importer.Free;
HTMLViewer.Free;
end;
end;
PRichEdit.Format;
PRichEdit.ReadOnly := false;
end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I do not know why it happens, but FireFox does not want to open google on my computer. I tried to paste using IE, Chrome and Safari, but I did not noticed wrong characters.
May be I overlooked them? Please send a screenshot to richviewgmailcom.
Post Reply