Re: How do I display unicode characters in a web page using an isapi
dll?
Thank you very much for your help and quick response.
It has solved our issue. I can't thank you enought. :-)
On Jan 18, 2:37 pm, "Giovanni Dicanio" <giovanni.dica...@invalid.com>
wrote:
There are several encodings for Unicode, like UTF-8 and UTF-16.
std::wstring or Windows WCHAR are Unicode UTF-16. Unicode UTF-16 is fine f=
or
internal processing inside a Windows application.
But, in general, when you move Unicode text and strings over the web (also=
in HTML pages) outside an application boundaries, you usually use Unicode
UTF-8.
In fact, when I read your source code, I found that you clearly declared
that you do use Unicode UTF-8 in your HTML:
html = L"<html><head><meta ht=
tp-equiv='content-type'
content='text/html; charset=utf-8' /></head><body><p>=C6=BB=EF=BF=BD=
=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=CB=BE</p></
body></html>";
[see "charset=utf-8" --> it means that you are using UTF-8 as Unicode
encoding for the HTML]
So, my guess is that you are declaring that you are going to use Unicode
UTF-8, but instead you are actually using UTF-16.
I think you should convert your Unicode UTF-16 text (including Chinese
"characters") into UTF-8 (e.g. using ::WideCharToMultiByte Win32 API,
specifiying CP_UTF8 as CodePage ID:
http://msdn2.microsoft.com/en-us/library/ms776420(VS.85).aspx
Giovanni
"Ryan" <rwag...@iconect.com> ha scritto nel messaggionews:88430573-f36b-44=
e8-9ed6-6d5596c5f75f@j20g2000hsi.googlegroups.com...
I have an ISAPI extension DLL that needs to output unicode data using
the WriteClient() function. The unicode characters are not displayed
properly. The text that is displayed in the web browser looks like
garbage even though viewing the source HTML shows Chinese characters
correctly.
DWORD WINAPI HttpExtensionProc(EXTENSION_CONTROL_BLOCK *pECB)
{
DWORD dwLength;
std::wstring html;
html = L"<html><head><meta htt=
p-equiv='content-type'
content='text/html; charset=utf-8' /></head><body><p>=C6=BB=EF=BF=BD=
=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=CB=BE</p></
body></html>";
dwLength = (DWORD) html.length=
();
dwLength = dwLength * sizeof(w=
char_t);
int rc = pECB->WriteClient(pEC=
B->ConnID, (LPVOID)
html.c_str(), &dwLength, HSE_IO_SYNC);
return HSE_REQ_DONE_WITH_SESSION=
;
}
Any help would be greatly appreciated.