November 23rd, 2010, 10:28 AM
Win32 API multilanguage conversion WCHAR,TCHAR problem?
I am using recv() func for "GET"ting a web content on port80. And try printing the received content on an Edit Controlon screen, by using ::SendMessage(...WM_SETTEXT...)
Due to the limitations of pointer types to be compliant to the func presets, I have to make some conversion.
Everything works fine, with latin letters but I can not anyhow manage to output the foreign language characters properly. Let's say russian.
How can I do this?Do I need to somehow change the edit control's character set, so as to interpret the passed string buffer as I wish? If so, how?I'll appreciate your help.
Here I enclose a short abstract from my code (as u might see I enforce UNICODE compilation)
#define RECBUFF 100000
bool KNetCon::WriteToScr(HWND hEditCtl)
// ----clear screen in edit
char *sendbuf="GET / HTTP/1.0 \r\n\r\n";
TCHAR* temp=wrecbuf; //*** NOTE: wrecbuf is the main buffer in (this)object.
// and declared in the class interface as ; TCHAR wrecbuf[RECBUFF]
//***recbuf declared in class interface as:
// char recbuf[RECBUFF] in
if(bytes_received==0 || bytes_received==WSAECONNRESET || bytes_received < 0)
*temp=L'\0';// **I am not sure if this is necessary or not,but
// the intention is form a null-terminating string.
mbstowcs(temp,recbuf,bytes_received); // I think this it the vital part..right???
// maybe smthg wrong here?
Last edited by Marc G; November 30th, 2010 at 03:55 AM.
Reason: Added code tags
November 24th, 2010, 12:46 AM
Re: Win32 API multilanguage conversion WCHAR,TCHAR problem?
HTTP does not deal in TCHAR's - just octects, or char's.
The char string that you recv will have a particular encoding: http://en.wikipedia.org/wiki/Charact...odings_in_HTML
You'll then need to convert that into a Windows wchar_t string, typically via MultiByteToWideChar() where the codepage parameter corresponds to the HTTP/HTML encoding that was recv'd.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!