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;
}
最新文章
- SpringMVC+Shiro权限管理【转】
- c++中的重名问题
- 【JAVA】LOG4J使用心得
- spring MVC 详细入门
- 使用grep恢复被删除文件内容【转】
- 【转】禁止seekbar的拖动事件
- 【转】Mac访问Windows共享文件夹
- 【转】Linux 上的最佳 C/C++ IDE
- <;c>;----<;choose>;<;when>;<;otherwise>;
- django之快速分页
- jquery总结(来自于一个讲师的总结)
- Javaweb 项目内所有页面都是404问题
- 线程池ThreadPoolExecutor源码解读研究(JDK1.8)
- Mysql锁机制--并发事务带来的更新丢失问题
- Gym 102091L Largest Allowed Area 【二分+二维前缀和】
- MT7628如何配置使用 Openwrt路由模式 (校园网配置)
- Linux日志文件总管——logrotate
- 2018.10.08 NOIP模拟 斐波那契(贪心+hash/map)
- g2o error2
- mysql的一些规范
热门文章
- Dijkstra+SPFA 模板
- SpringCloud(一)
- java课程学习心得
- Keras高层API之Metrics
- javaweb实现注册页面(数据库连接以及ajax验证)
- MySQL在大数据、高并发场景下的SQL语句优化和";最佳实践";
- P4072 [SDOI2016]征途
- npm ERR! Cannot read property &#39;match&#39; of undefined
- 使用IntersectionObserver制作滚动动画以及其他记录
- exe 发布为服务