我爱Aspx >> VC.Net >> WindowsCE下Unicode和Ansi字符间互相转换的例子WC_COMPOSITECHECK | WC_DEFAULTCHAR, //转换出错用缺省字符代替
tmpstr.GetBuffer(m_snd.GetLength()), //要转换的字符串地址
m_snd.GetLength(), //要转换的个数
0, //转换后字符串放置的地址
0, //最多转换字符的个数,为0表示返回转换Unicode后需要多少个字节
0, //缺省的字符:"\0"
0 //缺省的设置
);
WideCharToMultiByte( //转换Unicode到Ansi
CP_ACP,
WC_COMPOSITECHECK | WC_DEFAULTCHAR,
tmpstr.GetBuffer(m_snd.GetLength()),
m_snd.GetLength(),
(char *)buf, //转换到缓冲区中
128, //最多128个字节
0,
0
);
int sendcount=m_psocket->Send(buf,multibytelen+1); //发送转换后的缓冲区
CString statusstr;
statusstr.Format(TEXT("共发送字节数:%d"),sendcount);
m_status.SetWindowText(statusstr); //更新显示栏
}
程序接收到的字符串最后保存到CString tmpstr中.
//接收函数片断
void MyCeSocket::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
【我对这篇文章有话说?】
关联自己的应用程序到右键菜单中[05-21]
实战DeviceIoControl 之二:获取..[05-21]
非议MFC(三)库代码的质量问题[05-21]
从WEB服务器下载文件的简单方法。[05-21]
非议MFC(二)逻辑上的不完备[05-21]
实战DeviceIoControl 之一:通过..[05-21]
Windows中文输入法的实现[05-21]
用Delphi 6开发ASP上传组件详解[05-21]
”新快乐时光“再解[05-21]
Notes中有关C++API的注意事项[05-21]