宽字节 转换 单字节

前些天写补丁时间遇到的

读取一个寄存器的一个地址

地址的内容是宽字节

转换了好大一会儿
记录代码如下

char* WcharToChar(wchar_t* wc)   
{   

    int len= WideCharToMultiByte(CP_ACP,0,wc,wcslen(wc),NULL,0,NULL,NULL);   
    char* m_char=new char[len+1];   
    WideCharToMultiByte(CP_ACP,0,wc,wcslen(wc),m_char,len,NULL,NULL);   
    m_char[len]='\0';   
    return m_char;   
}

猜你喜欢

转载自blog.csdn.net/h1028962069/article/details/52665945