Solved

WebBrowser outerHTML and '??????'

Posted on 2010-11-18
7
1,118 Views
Last Modified: 2012-05-10
Hi,

I have problem with getting source from webbrowser. Some charakters are replaced with question marks. Iam using Delphi 7

0
Comment
Question by:lavitz
  • 3
  • 3
7 Comments
 
LVL 9

Expert Comment

by:Mahdi78
ID: 34163262
Try this

Memo1.Text := WebBrowser1.OleObject.Document.documentElement.innerHTML;
0
 
LVL 24

Expert Comment

by:jimyX
ID: 34163449
What is the code the you are using ?

Here is the right way to do that:
http://delphi.about.com/od/adptips2005/qt/webbrowserhtml.htm

uses mshtml;

var
    iall : IHTMLElement;
begin
   if Assigned(WebBrowser1.Document) then
   begin
     iall := (WebBrowser1.Document AS IHTMLDocument2).body;

     while iall.parentElement <> nil do
     begin
       iall := iall.parentElement;
     end;
     memo1.Text := iall.outerHTML;
   end;
end;

Open in new window

0
 

Author Comment

by:lavitz
ID: 34166506
I have made simple test on new project.
WebBrowser navigates prepared html file, and show it in tmemo.
Code is like jimyX: described.
And unfortunately i still have ????? in memo.

There is nothing  i could do wrong.

html file that i have loaded have charset=utf-8 and characters iam wrote  was cyrillic.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 24

Expert Comment

by:jimyX
ID: 34167182
Set your memo font to "Arial Unicode MS".
0
 

Author Comment

by:lavitz
ID: 34170899
didnt work.

html code (in place of ??????? is cyrillic, i dont know why EE dosnt save it)
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body>
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿<br>
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿<br>
¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿gfd<br>
</body></html>

Open in new window


delphi code
 
procedure TForm1.Button2Click(Sender: TObject);
var
    iall : IHTMLElement;
begin
   if Assigned(WebBrowser1.Document) then
   begin
     iall := (WebBrowser1.Document AS IHTMLDocument2).body;

     while iall.parentElement <> nil do
     begin
       iall := iall.parentElement;
     end;
     memo1.Text := iall.outerHTML;
   end;
end;

Open in new window

0
 
LVL 24

Accepted Solution

by:
jimyX earned 500 total points
ID: 34171035
That works if you write directly on the memo from the keyboard (I tried Chinese on my PC which is not configured to Chinese language and it worked).

Anyway let's get the string decoded using UTF8Decode:
memo1.Text := UTF8Decode(iall.outerHTML);
or,
memo1.Text := Utf8ToAnsi(iall.outerHTML);

If also not working (and that's because Delphi 7 default components do not support Unicode/UTF-8) you have to use another components that support Unicode, such as:

http://www.tntware.com/tntmpd/downloads/p/11083.aspx
or
http://www.tmssoftware.com/site/tmsuni.asp
0
 

Author Closing Comment

by:lavitz
ID: 34171768
It works with different components(tnt)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
code issue 8 157
URL for downloading Google Chrome for Win XP 2 194
How to convert memory stream to PDF file 6 125
Firemonkey android show image from resource ? 1 46
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question