当前位置: 技术问答>linux和unix
openssl 编程中制作证书,宽字节码的一个问题(附代码)
来源: 互联网 发布时间:2016-12-09
本文导语: RT bool Add_Name(X509_NAME * x509name, int type/*ccn*/, char * iput/*中国*/, int ilen/*输入长度*/, char * outMsg)//支持中文名称 { wchar_t * ws = NULL; wchar_t wc; ASN1_STRING stmp, *str = &stmp; UCHAR cbuf[256] = { 0 }; int wslen, wcnt,...
RT
bool Add_Name(X509_NAME * x509name, int type/*ccn*/, char * iput/*中国*/,
int ilen/*输入长度*/, char * outMsg)//支持中文名称
{
wchar_t * ws = NULL;
wchar_t wc;
ASN1_STRING stmp, *str = &stmp;
UCHAR cbuf[256] = { 0 };
int wslen, wcnt, i;
char input[256] = { 0 };
strncpy(input, iput, ilen);
wslen = strlen(input) + 1;
memset(&stmp,0,sizeof(stmp));
if (wslen == 1)
return TRUE;
//wslen -= 1;
/* REMOVE ws =new unsigned short[sizeof(wchar_t) * wslen]; */
ws = malloc(sizeof(wchar_t) * wslen);
if ((wcnt = mbstowcs(ws, input, wslen)) == -1) {
sprintf(outMsg, "mbstowcs convert error");
free(ws);
return FALSE;
}
for (i = 0; i