Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TWebBrowser - how to read Unicode UTF-8 characters from 'innerhtml' ?

214 views
Skip to first unread message

Adlib

unread,
Nov 10, 2003, 8:44:02 PM11/10/03
to
Hello

I'm attempting to read html from a tWebBrowser component (Delphi 7) like
this :

function GetHtml:widestring;
var bod:variant;
begin
bod:=doc.frames.editbox.document.body;
result:=bod.innerhtml;
ShowMessage(inttostr(length(result))+' : '+result);
end;

(in the above doc:=IWebBrowser(pDisp).Document;)

This works fine until the html contains characters from a non-Western
alphabet (for example Greek). The tWebBrowser component displays the Greek
characters OK, but when I read the 'innerhtml' property all the Greek
characters are converted to question marks (???).

What is the correct way to read 'innerhtml' so the non-Western characters
are not destroyed?

Regards,
Adlib


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.538 / Virus Database: 333 - Release Date: 10/11/2003


Bernhard Geyer

unread,
Nov 11, 2003, 2:11:37 AM11/11/03
to
ShowMessage is only a Ansi-Function.
For displaying Unicode-Strings of a different Codepage correct, you need
Unicode/Widestring-Functions
The easiest way is to use the MessageBoxW-Function in Windows.pas

If you want to work intensive with Unicode, you have to use some
Unicode-Enabled-Package:

http://home.ccci.org/wolbrink/tnt/delphi_unicode_controls.htm: Free
Unicode-Pack for WinNT-2003
http://www.lmdinnovative.com/products/lmdelpack/: Unicode-Pack for
Win95-2003 with enhanced controls

"Adlib" <nos...@nospam.nospam> schrieb im Newsbeitrag
news:3fb0...@newsgroups.borland.com...

Adlib

unread,
Nov 11, 2003, 8:55:01 AM11/11/03
to
Thanks Bernhard - now I understand. Are all Delphi components Ansi only? I
need to store this data in a TStringlist ...but looking at the help file I
suspect this is also Ansi only. Is there a TStringlist component for
widestrings?

Thanks for the links too,
Adlib

(Thinks... If Delphi components are all Ansi, then this would also explain
why I get reports from users in other countries that they are unable to
paste text from the Windows clipboard into my software...)


"Bernhard Geyer" <Bernhar...@nospam.com> wrote in message
news:3fb08ba9$1...@newsgroups.borland.com...

Fikret Hasovic

unread,
Nov 11, 2003, 8:45:41 AM11/11/03
to
Adlib wrote:

> Thanks Bernhard - now I understand. Are all Delphi components Ansi
> only? I need to store this data in a TStringlist ...but looking at
> the help file I suspect this is also Ansi only. Is there a
> TStringlist component for widestrings?
>

try with Tnt Delphi Unicode Controls

http://home.ccci.org/wolbrink/tnt/delphi_unicode_controls.htm

In unit TntClasses there is TTntStringList class;

> Thanks for the links too,
> Adlib
>
> (Thinks... If Delphi components are all Ansi, then this would also
> explain why I get reports from users in other countries that they are
> unable to paste text from the Windows clipboard into my software...)
>

--
Best regards
Fikret Hasovic
Posted with XanaNews 1.15.7.4

Bernhard Geyer

unread,
Nov 11, 2003, 4:55:32 PM11/11/03
to

> Thanks Bernhard - now I understand. Are all Delphi components Ansi only? I
> need to store this data in a TStringlist ...but looking at the help file I
> suspect this is also Ansi only. Is there a TStringlist component for
> widestrings?

Yes. VCL is nealy 100% ANSI. CLX is about 20-30% Unicode-Enabled (Delphi6)

Look at the Links to TNT-Controls and ElPack.

Both Support Unicode-Controls and Helper-Functions/Classes to support
Unicode. ElPack does support Unicode unter Win9x-2003 and
enhanced-controls. We use this controls to enhance our applicaton to
support unicode with only minor problems.

Adlib

unread,
Nov 11, 2003, 7:08:18 PM11/11/03
to
Thanks - I've downloaded the Tnt controls and will try them out soon.

I also found a quick work around to the immediate problem - by using the
Utf8Decode and Utf8Encode functions I can store and retrieve the widestrings
to/from an ordinary (Ansi) TStringlist without losing any information.
That's saved me from having to rewrite a lot of existing code (for now).

Regards,
Adlib

"Bernhard Geyer" <Bernhar...@gmx.de> wrote in message
news:3fb1...@newsgroups.borland.com...

Version: 6.0.538 / Virus Database: 333 - Release Date: 11/11/2003


Lo Yuk Fai

unread,
Nov 17, 2003, 1:15:33 PM11/17/03
to
That's a good idea. But beware of database app. and 3rd party tools,
in which dbExpress doesn't seem to recognize WideStrings and therefore
you can't use the Tnt data-aware controls (if you know, please tell
me!). Also Rave and most other 3rd party tools are not capable of
handling WideStrings too.

"Adlib" <nos...@nospam.nospam> wrote in message news:<3fb176c1$1...@newsgroups.borland.com>...

0 new messages