windows核心编程随笔

MultiByteToWideChar(char *转Unicode)

    char text[256] = {0};

    char text1[256] = {0};

    int i=0;



    GetDlgItemTextA(this->m_hWnd,IDC_EDIT1,text,256);

    int j= strlen(text);

    while (j)

    {

        text1[i] = text[j-1];

        i++;

        j--;

    }

    int len = MultiByteToWideChar (CP_ACP, 0, text1, -1, NULL, 0);

    TCHAR* text2 = new TCHAR [len];

    MultiByteToWideChar (CP_ACP, 0, text1, -1, text2, len);

    SetDlgItemTextW(IDC_TEXTOUT,text2);

    //SetDlgItemTextA(this->m_hWnd,IDC_TEXTOUT,text1);

    delete []text2;
WideCharToMultiByte(Unicode转char *)



    WCHAR text[256] = {0};

    WCHAR text1[256] = {0};

    int i=0;



    GetDlgItemTextW(IDC_EDIT1,text,256);

    int j= wcslen(text);

    while (j)

    {

        text1[i] = text[j-1];

        i++;

        j--;

    }

    int len = WideCharToMultiByte (CP_ACP,NULL,text1,-1,NULL,0,NULL,FALSE);

    char* text2 = new char [len];

    memset(text2,0,len);

    WideCharToMultiByte (CP_ACP,NULL,text1,-1,text2,len,NULL,FALSE);

    SetDlgItemTextA(this->m_hWnd,IDC_TEXTOUT,text2);



    delete []text2;

 

你可能感兴趣的:(windows)