Unicode与Ansi相关内容汇总

关于两种字符

Tips(From windows 核心编程)

MFC Unicode VS Ansi多字节

英文系统显示乱码

refer:

https://blog.csdn.net/hu_jinghui/article/details/80162640?utm_source=blogxgwz0

https://blog.csdn.net/wrnxrbb/article/details/80791960?utm_source=blogxgwz0

 

char与wchar_t之间的转换

    char与wchar_t类型数据之间的转换不能通过赋值的方式进行,只能通过 WideCharToMultiByte 和 MultiByteToWideChar 两个系统函数进行,这两个系统函数都在

wchar_t转char

char * wchar2char(const wchar_t* wchar )
{
    char * m_char;    
    int len= WideCharToMultiByte( CP_ACP, 0, wchar, wcslen(wchar), NULL, 0, NULL, NULL );    
    m_char= new char[len+1];     
    WideCharToMultiByte( CP_ACP, 0, wp, wcslen(wchar), m_char, len, NULL, NULL );     
    m_char[len]= '\0';     
    return m_char; 
}

char转wchar_t

wchar_t * char2wchar(const char* cchar) 
{     
    wchar_t *m_wchar;    
    int len = MultiByteToWideChar( CP_ACP, 0, cchar, strlen(cchar), NULL, 0);     
    m_wchar= new wchar_t[len+1];     
    MultiByteToWideChar( CP_ACP, 0, cchar, strlen(cchar), m_wchar, len);     
    m_wchar[len]= '\0' ;    
    return m_wchar; 
} 

refer:

https://blog.csdn.net/bailang_zhizun/article/details/80348282

你可能感兴趣的:(编程)