Hi,
I wrote a server program in redflag(almost like redhat). I am using 'char' buffer to send the message to client(running in windows). I succeed in communicating between server and client. when i try to print the message in client(code written in vc++, and the receive buffer type is TCHAR), it is printing in the form of boxes.
After i realised that the size of wchar_t in unix is 32 bit and in win32 it is 16 bit. si i used iconv() call to convert to 16 bit format and trying to send, but this time, I am able to send 4 characters only.
pls suggest some ideas to make compatible communication between windows ang linux.
Thankz in Advance.
converting function from utf8 to utf-16
Code:
char* convert(char* inbuf, int length)
{
iconv_t cd;
char *instr;
char *outbuf;
char *outptr;
unsigned int insize=length;
unsigned int outputbufsize=4096;
unsigned int avail=outputbufsize;
unsigned int nconv;
instr=inbuf;
outbuf=(char *)malloc(outputbufsize);
outptr=outbuf;
memset(outbuf,'\0',outputbufsize);
cd=iconv_open("utf-16", "utf-8");
if(cd==(iconv_t)-1)
{
printf("fail.\n");
}
nconv=iconv(cd,&instr,&insize,&outptr,&avail);
return outbuf;
}