zoukankan      html  css  js  c++  java
  • UNICODE下CString转string

    真搞不懂,为毛C++这么多类型转换。。

    CString m_str(_T("fuck conversion"));

    char *chr=new char[m_str.GetLength()+1];
    WideCharToMultiByte(CP_ACP,0,m_str.GetBuffer(),-1,chr,m_str.GetLength()+1,NULL,NULL);
    string str=chr;

    cout<<str;

    2、char转string

    char ch[10] = {0};

    itoa(i, ch, 10);

    std::string str = (char *)ch;

    3、int转byte

    public byte[] intToByte(int i) {
            byte[] abyte0 = new byte[4];
            abyte0[0] = (byte) (0xff & i);
            abyte0[1] = (byte) ((0xff00 & i) >> 8);
            abyte0[2] = (byte) ((0xff0000 & i) >> 16);
            abyte0[3] = (byte) ((0xff000000 & i) >> 24);
            return abyte0;
        }
    4、byte转int
    public  static int bytesToInt(byte[] bytes) {
            int addr = bytes[0] & 0xFF;
            addr |= ((bytes[1] << 8) & 0xFF00);
            addr |= ((bytes[2] << 16) & 0xFF0000);
            addr |= ((bytes[3] << 24) & 0xFF000000);
            return addr;
        }

  • 相关阅读:
    虚拟用户图分析
    概要图分析
    服务器资源监控视图
    场景监控之基本信息
    controller场景设计
    ip欺骗
    面试准备
    性能测试
    (一)总结
    bug的描述
  • 原文地址:https://www.cnblogs.com/yzl050819/p/8417600.html
Copyright © 2011-2022 走看看