Solved

WebBrowser outerHTML and '??????'

Posted on 2010-11-18
7
1,151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month8 days, 11 hours left to enroll

617 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