zoukankan      html  css  js  c++  java
  • 字符串的ASCII 读写

    CString CMacroCmd::String2Ascii(CString strValue)
    {
    #ifdef UNICODE
    CString strAscii = _T("");
    for (int i=0; i<strValue.GetLength(); i++)
    {
    CString stemp;
    stemp.Format(_T("%04X"), strValue.GetAt(i));

    strAscii = strAscii+stemp;
    }
    return strAscii;
    #else
    ASSERT(FALSE); // 必须是UNICODE
    return strValue;
    #endif
    }

    CString CMacroCmd::Ascii2String(CString strAscii)
    {
    #ifdef UNICODE
    CString strValue = _T("");

    int tch1 = 0; //TCHAR tch1 = 0x0000; 原因参考 http://www.cnblogs.com/carl2380/archive/2011/06/21/2086011.html
    for (int i=0; i<strAscii.GetLength()/4; i++)
    {
    CString stemp1 = strAscii.Mid(i*4, 4);

    _stscanf_s(stemp1.GetBuffer(0),_T("%x"),&tch1);

    CString stemp3;
    stemp3.Format(_T("%c"), tch1);
    strValue = strValue+stemp3;
    }
    return strValue;
    #else
    ASSERT(FALSE); // 必须是UNICODE
    return strAscii;
    #endif
    }

  • 相关阅读:
    spark 脚本示例
    R树的应用
    将博客搬至CSDN
    select
    注册页面的验证码的实现
    web项目.注册及登陆
    eclipse web 项目中遇到的问题总结
    Apache与Tomcat
    关于MVC整理
    JDBC
  • 原文地址:https://www.cnblogs.com/carl2380/p/2307248.html
Copyright © 2011-2022 走看看