char ch[7];
ch[0] = 0x20;
ch[1] = 0x20; 
ch[2] = 0x2E;
ch[3] = 0xD9;
ch[4] = 0xD3;
ch[5] = 0xFE;
ch[6] = 0xD3;
int     unicodeLen=MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED,ch,-1,NULL,0);      如上代码,为什么unicodeLen的值为19?

解决方案 »

  1.   

    没有找到合适正确的字符结束符号int MultiByteToWideChar(
      UINT CodePage,         // code page
      DWORD dwFlags,         // character-type options
      LPCSTR lpMultiByteStr, // string to map
      int cbMultiByte,       // number of bytes in string
      LPWSTR lpWideCharStr,  // wide-character buffer
      int cchWideChar        // size of buffer
    );cbMultiByte 
    [in] Specifies the size in bytes of the string pointed to by the lpMultiByteStr parameter, or it can be -1 if the string is null terminated. Note that if cbMultiByte is 0, the function fails. 
      

  2.   

    选-1作参数的时候,要求字符串必须以0结尾char ch[8]; 
    ch[0] = 0x20; 
    ch[1] = 0x20; 
    ch[2] = 0x2E; 
    ch[3] = 0xD9; 
    ch[4] = 0xD3; 
    ch[5] = 0xFE; 
    ch[6] = 0xD3; 
    ch[7] = 0;