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
Upon paste html, strange characters in TRichEdit
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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;
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;
-
- Site Admin
- Posts: 17569
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: