Solved

TWebBrowser Unicode characters as Question Marks ??????

Posted on 2008-06-22
3
973 Views
Last Modified: 2013-11-23
I am getting titles from rssfeed and displaying them in a marquee in TWebBrowse control. But the titles are displayed as question marks. Look at my complete code.

WebBrowser is Navigated to Blank Page.
Downloads the RssFeed and Extract titles.
Write the HTML to WebBrowser.

Is there any string manipulation required to deal with unicode chars.
Even I tried Passing the titles to TMSUnicode Edit control. TMS Edit gets the string correctly and the same text is passed to WebBrowser. Kindly help me please. You may use the rssfeed link I am using in my code.

Thanks a lot.


procedure TRaftaar.GetHeadLines;

var

    newsxml: string;  ItemNode:IXMLNode;title:widestring; I:integer;

    nodelist:IXMLNodeList; html:widestring; link:widestring;
 

begin

  html := '<html><body scroll=no><marquee WIDTH=100% BEHAVIOR=SCROLL DIRECTION=left scrollamount=2 BGColor=yellow onmouseover=stop(); onmouseout=start();>';
 

  newsxml := IdHttp1.Get('http://www.raftaar.com/feeds/Home_News.xml');

  xmldocument1.XML.Text := newsxml;

  xmldocument1.Active := True;

  nodelist := xmldocument1.DocumentElement.ChildNodes.First.ChildNodes;

  for I:=0 to nodelist.Count-1 do

  begin

    ItemNode := nodelist[i];

    if ItemNode.NodeName='item' then

    begin

      title := itemnode.ChildNodes['title'].Text;

      link:=   itemnode.ChildNodes['link'].Text;

      html:= html+'<a name='+link+' href=#>'+title+'</a>&nbsp&nbsp||&nbsp&nbsp';

    end;
 

  end;

  html:= html+'</marquee></body></html>';

  WbNavBlank;

  LoadHtml(html,WebBrowser1);

  WbHideScrollBar(WebBrowser1);

  xmldocument1.Active := False;

end;
 
 

procedure TRaftaar.LoadHtml(html: string; WB:TWebBrowser);

   var IDoc: IHTMLDocument2;  v: OleVariant;

begin

  IDoc := WebBrowser1.Document as  IHTMLDocument2;

  v := VarArrayCreate([0, 0], varVariant);

  v[0] := html;

  IDoc.Write(PSafeArray(TVarData(v).VArray));

  IDoc.Close;

  IDoc.body.style.marginTop := -1;

  //IDoc.body.style.backgroundColor := 'Red';

  WbHideScrollBar(WebBrowser1);

  BindAnchors(IDoc);
 

end;.

Open in new window

0
Comment
Question by:SHAHEEN_AKHTAR
  • 2
3 Comments
 

Accepted Solution

by:
JustScreenShot earned 500 total points
ID: 21858119
Add following line to the header section of the output html.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Open in new window

0
 

Author Comment

by:SHAHEEN_AKHTAR
ID: 21862547
Already tried that. But all question marks displayed. I am getting the output HTML correctly. I append the HTML below:-

I think there is some thing to do with the TWebBrowser or IHTMLDocument2 Character set. I am trying that and come back.

Thanks


'<html><head><META http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body scroll=no><marquee WIDTH=100% BEHAVIOR=SCROLL DIRECTION=left scrollamount=2 BGColor=yellow onmouseover=stop(); onmouseout=start();><a name=http://www.raftaar.com/IndexI.aspx?__EVENTTARGET=main&__EVENTARGUMENT=%E0%A4%97%E0%A4%82%E0%A4%97%E0%A4%BE%20%E0%A4%95%E0%A5%8B%20%E0%A4%B2%E0%A5%87%E0%A4%95%E0%A4%B0%20%E0%A4%85%E0%A4%A8%E0%A4%B6%E0%A4%A8%20%E0%A4%86%E0%A4%9C~1~IE~web~~hi~web~~~~news href=#>> K 2G0 (6( </a>&nbsp&nbsp||&nbsp&nbsp<a name=http://www.raftaar.com/IndexI.aspx?__EVENTTARGET=main&__EVENTARGUMENT=%E0%A4%97%E0%A5%80%E0%A4%A4%E0%A4%BE%20%E0%A4%B0%E0%A4%BE%E0%A4%AE%E0%A4%BE%E0%A4%AF%E0%A4%A3%20%E0%A4%94%E0%A4%B0%20%E0%A4%AA%E0%A5%81%E0%A4%B0%E0%A4%BE%E0%A4%A3%20%E0%A4%A4%E0%A4%BE%E0%A4%AE%E0%A5%8D%E0%A4%B0%E0%A4%AA%E0%A4%A4%E0%A5%8D%E0%A4%B0%20%E0%A4%AA%E0%A4%B0~1~IE~web~~hi~web~~~~news href=#>@$> 0>.>/# 0 *A0># $>.M0*$M0 *0</a>&nbsp&nbsp||&nbsp&nbsp<a name=http://www.raftaar.com/IndexI.aspx?__EVENTTARGET=main&__EVENTARGUMENT=%E0%A4%87%E0%A4%9F%E0%A4%B2%E0%A5%80%20%E0%A4%95%E0%A5%8B%20%E0%A4%B9%E0%A4%B0%E0%A4%BE%E0%A4%95%E0%A4%B0%20%E0%A4%B8%E0%A5%8D%E0%A4%AA%E0%A5%87%E0%A4%A8%20%E0%A4%B8%E0%A5%87%E0%A4%AE%E0%A5%80%E0%A4%AB%E0%A4%BC%E0%A4%BE%E0%A4%87%E0%A4%A8%E0%A4%B2%20%E0%A4%AE%E0%A5%87%E0%A4%82~1~IE~web~~hi~web~~~~news href=#>2@ K 90>0 8M*G( 8G.@+<>(2 .G</a>&nbsp&nbsp||&nbsp&nbsp<a name=http://www.raftaar.com/IndexI.aspx?__EVENTTARGET=main&__EVENTARGUMENT=%E0%A4%9C%E0%A4%B9%E0%A4%BE%E0%A4%9C%E0%A4%BC%20%E0%A4%95%E0%A5%87%2028%20%E0%A4%AF%E0%A4%BE%E0%A4%A4%E0%A5%8D%E0%A4%B0%E0%A5%80%20%E0%A4%9C%E0%A5%80%E0%A4%B5%E0%A4%BF%E0%A4%A4%20%E0%A4%AE%E0%A4%BF%E0%A4%B2%E0%A5%87~1~IE~web~~hi~web~~~~news href=#>9>< G 28 />$M0@ @5?$ .?2G</a>&nbsp&nbsp||&nbsp&nbsp</marquee></body></html>

Open in new window

0
 

Author Closing Comment

by:SHAHEEN_AKHTAR
ID: 31469642
It was my fault. In the Load HTML function I was passing the HTML in a string variable instead of widestring. Changing it to widestring solved the problem. Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now