Title: Message
Ehsan,
 
Thanks for the quick reply.
 
I tried using a different approach to writing the html content into the webbrowser. (find code below).
 
This seems to work fine. From this i conclude that the problem was not the MultiByteToWideChar that caused the problem, rather, the use of IPersistStreamInit.
 
Do you see any way that the use of the stream can change the encoding of the string?
 
CString testString someString;
int bufSize = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)testString , -1, NULL, 0);
WCHAR* lpWideCharStr = new WCHAR[bufSize];
int rc = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)testString , -1, lpWideCharStr, bufSize);
HRESULT hr;
VARIANT vEmpty, *v;
IDispatch *pDisp=NULL;
SAFEARRAY *sfa = NULL;
IHTMLDocument2 *m_pDoc=NULL;
pDisp = sessionsCtrl.GetDocument();
hr = pDisp->QueryInterface(IID_IHTMLDocument2, (void **)&m_pDoc);
sfa = SafeArrayCreateVector(VT_VARIANT, 0, 1);
hr = SafeArrayAccessData(sfa,(LPVOID*)&v);
v->vt = VT_BSTR;
v->bstrVal = SysAllocString(lpWideCharStr);
hr = SafeArrayUnaccessData(sfa);
hr = m_pDoc->write(sfa);
m_pDoc->close();
m_pDoc->Release();
pDisp->Release();
 
Michal
-----Original Message-----
From: Ehsan Akhgari [mailto:[EMAIL PROTECTED]
Sent: Monday, September 08, 2003 5:05 PM
To: [EMAIL PROTECTED]
Subject: RE: [MSVC] Problem with HTMLWriter

 
Ehsan,
 
If you recall, i had a problem with the HTMLWriter. The problem was solved by changing the string passed to the document to be in UNICODE rather than multi byte.
 
Now i seem to have a problem with language support. If the string holds characters in Hebrew for example, the Hebrew characters are not translated correctly. I.e i see gibberish in the browser window where the Hebrew characters should be shown.
 
Same problem occurs for Chinese, Russian.
 
I suspect the problem is related to the code page that i pass to the MultiByteToWideChar.
I tried different codes. CP_ACP works on win2000 but not on winXP.
 
Could you please let me know what it is that i'm doing wrong? 
The problem may have several causes:
 
1.  You may not have correct fonts installed on the system.
2.  Your IE might not have the required language support pack installed (this can be solved by creating a custom version of IE setup through the IEAK.)
3.  You may be passing the wrong code page to WideCharToMultiByte( )
4.  You may be specifying the wrong code page (charset) in the HTML page.
 
The easiest solution is using UTF-8.  IE internally supports it.  You encode the text into UTF-8, and specify the correct charset in the HTML code - that is all.

---------
Ehsan Akhgari

List Owner: [EMAIL PROTECTED]

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

Freedom from fever is still far from being knowledge! Refrigerated spirits I do not believe in. He who cannot lie, does not know what truth is.
-Thus Spoke Zarathustra, F. W. Nietzsche

Reply via email to