Article View: borland.public.cppbuilder.internet.socket
Article #2691Re: URLEncode and Unicode
From: Remy Lebeau (TeamB)
Date: Wed, 08 Feb 2006 18:51
Date: Wed, 08 Feb 2006 18:51
40 lines
2497 bytes
2497 bytes
"Peter Evans" <peter-evans@pelcaro.com> wrote in message
news:43e9cfd9$1@newsgroups.borland.com...
> I made the following work OK, but it uses CppWebBrowser1->Navigate,
> from NetMasters, to pull the page in !
TCppWebBrowser is not a NetMasters component. It is a Borland component
wrapper around the Internet Explorer COM object.
> //make wide string from the URL that has been read in
from file
> //get space, and calc length
> wchar_t wcURL[256+1]; int iURL=2*strlen((const
char*)csURL)+1;
> //
> //change to wide / BSTR
> StringToWideChar((String)csURL,wcURL,iURL);
> //
> //load down the first page of the website
> CppWebBrowser1->Navigate(wcURL);
There is an easier way to do that:
CppWebBrowser1->Navigate(WideString(csURL));
> Incidentally, the following seems to work without problem as well:
>
> CppWebBrowser1->Navigate(L"AnyPieceOfGoodHtml.html");
That is very dangerous. Navigate() expects a BSTR. Using the 'L' keyword
*does not* produce a valid BSTR. All the 'L' keyword does is to tell the
compiler to create a wchar_t* constant instead of a char* constant. A BSTR,
on the other hand, is more than that. It has a 4-byte length value
preceeding the character memory. The 'L' keyword cannot produce that. You
need to use one of the Win32 API's SysAlloc...() functions (which are
wrapped by the WideString class) to produce valid BSTR values.
Gambit
Technical Details
Message-ID:
<43ea3cfc$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<43dc6a15$1@newsgroups.borland.com> <43e9cfd9$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,7fe0fd91d449167c X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <43dc6a15$1@newsgroups.borland.com> <43e9cfd9$1@newsgroups.borland.com> Subject: Re: URLEncode and Unicode Date: Wed, 8 Feb 2006 10:51:17 -0800 Lines: 42 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <43ea3cfc$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1139424508 68.69.17.41 (8 Feb 2006 10:48:28 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news4.google.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail