zoukankan      html  css  js  c++  java
  • V++ MFC CEdit输出数组 UNICODE TO ASCII码

    MFC怎么在静态编辑框中输出数组

    //字符转ASCII码
    void CUTF8Dlg::OnBnClickedButtonCharAscii()
    {
     // TODO: 在此添加控件通知处理程序代码
     UpdateData(TRUE);
     int length = 0;
     CStringW sAscii;
     char* pAscii;
     char aa[1024];
     GetDlgItem(IDC_EDIT_CHINA)->GetWindowText(sAscii);
     pAscii = ConvertUnicode2Ascii(sAscii);  //调用Unicode转ASCII函数

     while (TRUE)
     {
      if (*pAscii == 0)
      {
       break;
      }
      else
      {
       aa[length] = *pAscii;
       length++;
      }
      pAscii++;
     }
     CString bb[1024];
     for (int j = 0; j< length; j++)
     {
      bb[j].Format(_T("%x "),aa[j]);  /把十六进制数组添加到字符串 

      byUTF8 += bb[j];
     }
     UpdateData(FALSE);  //显示输出结果
    }

    //UNICODE TO ASCII
    char* CUTF8Dlg::ConvertUnicode2Ascii(CStringW &instr)
    {
     wchar_t * wstr = instr.GetBuffer();
     int ulen = ::WideCharToMultiByte(CP_ACP, 0, wstr, -1, NULL, 0, NULL, NULL);
     char* date = new char[ulen+1];
     memset(date,0,sizeof(char)*(ulen+1));//格式化字符串
     WideCharToMultiByte(CP_ACP, 0, wstr, -1, date, ulen, NULL, NULL);
     date[ulen+1] = '';//最后一字解设置结束符
     return date;
    }

  • 相关阅读:
    LCT 动态树 模板
    [HNOI2010] 物品调度 fsk
    [HNOI2010] 矩阵 matrix
    [HNOI2010] 平面图判定 planar
    [HNOI2010] 公交线路 bus
    [HNOI2017]抛硬币
    [HNOI2010] 弹飞绵羊 bounce
    [HNOI2010] 合唱队 chorus
    [HNOI2017]礼物
    [HNOI2017]大佬
  • 原文地址:https://www.cnblogs.com/ransn/p/8035487.html
Copyright © 2011-2022 走看看