Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-22
3
Medium Priority
?
994 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 1500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

824 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