已经有编码代码
char * PackData(CString message)
{
unsigned char * contentBytes = NULL;
CString temp;
ConvertGBKToUtf8(temp,(char *)message.GetString());
if (temp.GetLength() < 126){
contentBytes =(unsigned char *)malloc(temp.GetLength()+2);
contentBytes[0] = 0x81;
contentBytes[1] = (unsigned char)temp.GetLength();
strcpy((char *)contentBytes+2,temp.GetString());
}else if (temp.GetLength() < 0xFFFF){
contentBytes = (unsigned char *)malloc(temp.GetLength()+4);
contentBytes[0] = (unsigned char)0x81;
contentBytes[1] =(unsigned char) 126;
contentBytes[2] = (unsigned char)((unsigned char)temp.GetLength() & 0xFF);
contentBytes[3] = (unsigned char)((unsigned char)temp.GetLength() >> 8 & 0xFF);
strcpy((char *)contentBytes+4,temp.GetString());
}else{
// 暂不处理超长内容
}
return (char *)contentBytes;
}
跪求解码代码