我在Win CE下编制串口程序,因为CE只支持Unicode,所以想知道如何将其转化为Ascii码,这可能是个菜鸟问题,请指教

解决方案 »

  1.   

    int WideCharToMultiByte(
    UINT CodePage, 
    DWORD dwFlags, 
    LPCWSTR lpWideCharStr, 
    int cchWideChar, 
    LPSTR lpMultiByteStr, 
    int cbMultiByte, 
    LPCSTR lpDefaultChar, 
    LPBOOL lpUsedDefaultChar );
      

  2.   

    Unicode is an encoding standard in which all characters are two bytes long. Unicode characters are sometimes called wide characters because they are wider (use more storage) than single-byte characters. Note that Unicode is not considered an MBCS - the distinguishing feature of an MBCS encoding is that characters are of different lengths. A Unicode string is terminated by two zero bytes (the encoding of the value 0 in a wide character).unciode characters stored in memory:
    42 00 6F 00 62 00 00 00  
    B     o     b     EOSascii characters stored in memory:
    42 6F 62 00   
    B  o  b  EOS 
     
    Do this like it ;
     
      

  3.   

    其实你要做的只有两点:  解析一个UINCODE字符为两个CHAR
      注意结束标志