博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
utf8转unicode
阅读量:6271 次
发布时间:2019-06-22

本文共 3363 字,大约阅读时间需要 11 分钟。

#include 
#include
#include
#include
#include
#include
#define BYTE unsigned char/*// C prototype : void StrToHex(BYTE *pbDest, BYTE *pbSrc, int nLen)// parameter(s): [OUT] pbDest - 输出缓冲区// [IN] pbSrc - 字符串// [IN] nLen - 16进制数的字节数(字符串的长度/2)// return value: // remarks : 将字符串转化为16进制数*/void StrToHex(BYTE *pbDest, BYTE *pbSrc, int nLen){char h1,h2;BYTE s1,s2;int i;for (i=0; i
9) s1 -= 7;s2 = toupper(h2) - 0x30;if (s2 > 9) s2 -= 7;pbDest[i] = s1*16 + s2;}}/*// C prototype : void HexToStr(BYTE *pbDest, BYTE *pbSrc, int nLen)// parameter(s): [OUT] pbDest - 存放目标字符串// [IN] pbSrc - 输入16进制数的起始地址// [IN] nLen - 16进制数的字节数// return value: // remarks : 将16进制数转化为字符串*/void HexToStr(BYTE *pbDest, BYTE *pbSrc, int nLen){char ddl,ddh;int i;for (i=0; i
57) ddh = ddh + 7;if (ddl > 57) ddl = ddl + 7;pbDest[i*2] = ddh;pbDest[i*2+1] = ddl;}pbDest[nLen*2] = '\0';}int RS232_SendBuf(int comport_number,unsigned char *data_buf,int size){ char str[1024] = ""; HexToStr(str, data_buf, size); printf("str == %s\n", str); return 0;}int RS232_SxtBuf(int comport_number,int cardID,unsigned char cmd,unsigned char cmd_Sxt,unsigned char *buf,int size){ //unsigned char data_buf[size+8]; int i; int satae = -1; unsigned char data_buf[64]; switch(cmd) { case 0x50: // data_buf = (unsigned char*)malloc((size+7)*sizeof(unsigned char)); data_buf[0] = 0XA0; data_buf[1] = 0X90|((cardID>>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0x50; data_buf[4] = size/255; data_buf[5] = size%255; if(size != 0) { for(i = 0;i
>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0xA5; data_buf[4] = size/255; data_buf[5] = size%255; if(size != 0) { for( i = 0;i
>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0x58; if(size == 0) { data_buf[4] = 0; data_buf[5] = 0; data_buf[6] = data_buf[5]^data_buf[4]^data_buf[3]^data_buf[2]; satae = RS232_SendBuf(comport_number,data_buf,7); } else { data_buf[4] = 0; data_buf[5] = 1; data_buf[6] = 0xFF; data_buf[7] = data_buf[6]^data_buf[5]^data_buf[4]^data_buf[3]^data_buf[2]; satae = RS232_SendBuf(comport_number,data_buf,8); } break; case 0x48: data_buf[0] = 0XA0; data_buf[1] = 0X90|((cardID>>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0x48; data_buf[4] = 0; data_buf[5] = 1; data_buf[6] = cmd_Sxt; data_buf[7] = data_buf[6]^data_buf[5]^data_buf[4]^data_buf[3]^data_buf[2]; satae = RS232_SendBuf(comport_number,data_buf,8); break; case 0x49: // data_buf = (unsigned char*)malloc((size+9)*sizeof(unsigned char)); data_buf[0] = 0XA0; data_buf[1] = 0X90|((cardID>>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0x49; data_buf[4] = (size+1)/255; data_buf[5] = (size+1)%255; if(size != 0) { data_buf[6] = cmd_Sxt; for(i = 0;i
>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0x44; data_buf[4] = size/255; data_buf[5] = size%255; if(size != 0) { for(int i = 0;i
>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0x51; data_buf[4] = size/255; data_buf[5] = size%255; if(size != 0) { for( i = 0;i
>8)&0x0F); data_buf[2] =(unsigned char)(cardID&0x00ff); data_buf[3] = 0x52; data_buf[4] = size/255; data_buf[5] = size%255; if(size != 0) { for( i = 0;i

 

转载于:https://www.cnblogs.com/fdd566/p/6443891.html

你可能感兴趣的文章
潮鞋的AR初体验,鬼冢虎和Anrealage合作新鞋
查看>>
4星|《错误的行为》:经济行为中大部分时候人们是不理性的
查看>>
java中包容易出现的错误及权限问题
查看>>
Hibernate5-查询与排序
查看>>
硬盘速度测试
查看>>
mouseout、mouseover和mouseleave、mouseenter区别
查看>>
一句话命令
查看>>
TCP/IP
查看>>
redhat之root密码破解
查看>>
如何为xshell终端设置超时
查看>>
几点Java程序必须满足的基本规则
查看>>
开源数据库Sharding技术
查看>>
mysql用户管理、常用sql语句、mysql数据库备份恢复
查看>>
linux 下route命令
查看>>
关于exchange 2010在单林多域环境中创建邮箱问题
查看>>
常用的正则表达式
查看>>
delphi 操作文件
查看>>
AWS RDS多可用区+EC2实例跑mysql从库的测试
查看>>
oracle经典书籍推荐
查看>>
OCI,runC,containerd 是什么?(部分转载)
查看>>