Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

WebBrowser outerHTML and '??????'

Posted on 2010-11-18
7
Medium Priority
?
1,177 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

670 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