我写一个服务器和客户端,客户端输入cmd指令,服务器运行该指令,并将显示返回给客户端
当服务器在俄文虚拟机下运行时,输入ipconfig或ipconfig \all等指令时,在客户端显示会产生乱码
而输入诸如systeminfo等指令不会有乱码。给跪了,求救。代码如下
CString mid;
int ipc=0,ess=0;
DWORD dwRead=0;
TCHAR buff[610]={_T("0")};
ipc=((DWORD*)buf)[1];//判断指令是否为ipconfig或相关 //buf为char型数据
ess=((DWORD*)buf)[0];//判断是否为866(俄文编码)
dwRead=((DWORD*)buf)[2];//数据长度
char tempa[1000]={"0"};
pDlg->GetDlgItem(IDC_CMDSHOW)->GetWindowText(mid); //得到原edit中的显示
if (ess)//ess=1 是俄文
{
if(ipc) //ipc=1是ipconfig或相关命令
{
MultiByteToWideChar(CP_UTF8,0,buf+16,-1,buff,dwRead);
WideCharToMultiByte( 866, 0, buff, -1, tempa, 1000, NULL, NULL );// mid+=tempa;
}
else
{
MultiByteToWideChar(866,0,buf+16,-1,buff,dwRead);
mid+=buff;
}
}
else
{
MultiByteToWideChar(CP_ACP,0,buf+16,-1,buff,dwRead);
mid+=buff;
}
pDlg->GetDlgItem(IDC_CMDSHOW)->SetWindowText(mid);
pDlg->m_cmdshow.LineScroll(pDlg->m_cmdshow.GetLineCount()-1,0);
当服务器在俄文虚拟机下运行时,输入ipconfig或ipconfig \all等指令时,在客户端显示会产生乱码
而输入诸如systeminfo等指令不会有乱码。给跪了,求救。代码如下
CString mid;
int ipc=0,ess=0;
DWORD dwRead=0;
TCHAR buff[610]={_T("0")};
ipc=((DWORD*)buf)[1];//判断指令是否为ipconfig或相关 //buf为char型数据
ess=((DWORD*)buf)[0];//判断是否为866(俄文编码)
dwRead=((DWORD*)buf)[2];//数据长度
char tempa[1000]={"0"};
pDlg->GetDlgItem(IDC_CMDSHOW)->GetWindowText(mid); //得到原edit中的显示
if (ess)//ess=1 是俄文
{
if(ipc) //ipc=1是ipconfig或相关命令
{
MultiByteToWideChar(CP_UTF8,0,buf+16,-1,buff,dwRead);
WideCharToMultiByte( 866, 0, buff, -1, tempa, 1000, NULL, NULL );// mid+=tempa;
}
else
{
MultiByteToWideChar(866,0,buf+16,-1,buff,dwRead);
mid+=buff;
}
}
else
{
MultiByteToWideChar(CP_ACP,0,buf+16,-1,buff,dwRead);
mid+=buff;
}
pDlg->GetDlgItem(IDC_CMDSHOW)->SetWindowText(mid);
pDlg->m_cmdshow.LineScroll(pDlg->m_cmdshow.GetLineCount()-1,0);
buf前十二个字节分别3为是否为866,是否为ipconfig,回显的数据长度求大神,求大神
{
MultiByteToWideChar(CP_UTF8,0,buf+16,-1,buff,dwRead);
WideCharToMultiByte( 866, 0, buff, -1, tempa, 1000, NULL, NULL );// mid+=tempa;
}
各种代码页都试过了,cp_utf8,cp_utf7,cp_acp,....