SHAHEEN_AKHTAR
asked on
TWebBrowser Unicode characters as Question Marks ??????
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.
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>  ||  ';
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;.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
ASKER
I think there is some thing to do with the TWebBrowser or IHTMLDocument2 Character set. I am trying that and come back.
Thanks
Open in new window