Title: Message
Ehsan,
 
Thanks you very much for your help.
Your idea has solved my problem.
 
Here is the code for the HTMLWriter::Write that i changed:
 

bool CHTMLWriter::MyWrite(LPCTSTR pszHTMLContent)

{

if (!pszHTMLContent)

return false;

if (!GetDocumentPtr())

return false;

WCHAR lpWideCharStr[50000];

MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)pszHTMLContent, -1, lpWideCharStr, 50000);

IStream * pStream = NULL;

IPersistStreamInit * pPSI = NULL;

HGLOBAL hHTMLContent;

HRESULT hr;

bool bResult = false;

// allocate global memory to copy the HTML content to

SIZE_T dwBytes = ( ::wcslen(lpWideCharStr ) + 1 ) * sizeof(WCHAR);

hHTMLContent = ::GlobalAlloc( GPTR, dwBytes);

if (!hHTMLContent)

return false;

::wcscpy( (WCHAR *) hHTMLContent, lpWideCharStr );

// create a stream object based on the HTML content

hr = ::CreateStreamOnHGlobal( hHTMLContent, TRUE, &pStream );

if (SUCCEEDED(hr))

{

// request the IPersistStreamInit interface

hr = m_pDoc->QueryInterface( IID_IPersistStreamInit, (void **) &pPSI );

if (SUCCEEDED(hr))

{

// initialize the persist stream object

hr = pPSI->InitNew();

if (SUCCEEDED(hr))

{

// load the data into it

hr = pPSI->Load( pStream );

if (SUCCEEDED(hr))

bResult = true;

}

pPSI->Release();

}

// implicitly calls ::GlobalFree to free the global memory

pStream->Release();

}

return bResult;

}

-----Original Message-----
From: Ehsan Akhgari [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 10, 2003 10:04 PM
To: [EMAIL PROTECTED]
Subject: RE: [MSVC] Problem with HTMLWriter

 
I changed to windows-1252 but it still does not work.
 
However, i found the weirdest thing. I compiled the sample in release mode and run the application and it does work.
After some investigation i found in the project propeties that if i set the character set to 'Use Unicode Character Set' rather than 'Use Multi-Byte Character Set' it works .
 
Do u have any idea why that makes the difference.
 
The problem is that i cannot change my project character set to unicode. I need it to stay as Multi-Byte. 
Hmmm, maybe you're entering some characters which have glyphs similar to those acceptable by HTML in your system locale in your source code, which causes the HTML parser to fail to parse the file correctly?
 
OK, here is an idea: make your application use MBCS, but feed in Unicode strings as the HTML source code to the WebBrowser control.  You can use MultiByteToWideChar( ) to convert the strings to UFT-8 (preferrably) or UTF-16, and then specify the utf-8 or utf-16 charsets inside the <meta> tag.

---------
Ehsan Akhgari

List Owner: [EMAIL PROTECTED]

[Email: [EMAIL PROTECTED]; [EMAIL PROTECTED]]
[WWW: http://www.beginthread.com/Ehsan ]
 

Physician, heal thyself: then you will also heal your patient. Let it be his best cure to see with his eyes the man who heals himself.
-Thus Spoke Zarathustra, F. W. Nietzsche

Reply via email to