Page 1 of 1

Upon paste html, strange characters in TRichEdit

Posted: Tue Aug 26, 2014 8:22 pm
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

Posted: Tue Aug 26, 2014 9:20 pm
by Sergey Tkachenko
How to reproduce it?

Posted: Tue Aug 26, 2014 9:25 pm
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;

Posted: Wed Aug 27, 2014 8:05 am
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.