how convert large HEX string to binary array ?
how convert large HEX string to binary
I have a string with 14 characters . This is a hex represantation of 7bytes. I want to convert it to binary.
int32_t Hex2Bin( uint8_t * pHexString, uint8_t * pBinArray )
{
int o = ;
int i = ; while ( pHexString[ i ] != 0x00 )
{
switch ( pHexString[ i ] )
{
case '':
pBinArray[ o ] = 0x00;
break;
case '':
pBinArray[ o ] = 0x10;
break;
case '':
pBinArray[ o ] = 0x20;
break;
case '':
pBinArray[ o ] = 0x30;
break;
case '':
pBinArray[ o ] = 0x40;
break;
case '':
pBinArray[ o ] = 0x50;
break;
case '':
pBinArray[ o ] = 0x60;
break;
case '':
pBinArray[ o ] = 0x70;
break;
case '':
pBinArray[ o ] = 0x80;
break;
case '':
pBinArray[ o ] = 0x90;
break;
case 'A':
case 'a':
pBinArray[ o ] = 0xa0;
break;
case 'B':
case 'b':
pBinArray[ o ] = 0xb0;
break;
case 'C':
case 'c':
pBinArray[ o ] = 0xc0;
break;
case 'D':
case 'd':
pBinArray[ o ] = 0xd0;
break;
case 'E':
case 'e':
pBinArray[ o ] = 0xe0;
break;
case 'F':
case 'f':
pBinArray[ o ] = 0xf0;
break;
default:
return -;
} if ( pHexString[ i + ] == 0x00 )
return -; switch ( pHexString[ i + ] )
{
case '':
pBinArray[ o ] |= 0x00;
break;
case '':
pBinArray[ o ] |= 0x01;
break;
case '':
pBinArray[ o ] |= 0x02;
break;
case '':
pBinArray[ o ] |= 0x03;
break;
case '':
pBinArray[ o ] |= 0x04;
break;
case '':
pBinArray[ o ] |= 0x05;
break;
case '':
pBinArray[ o ] |= 0x06;
break;
case '':
pBinArray[ o ] |= 0x07;
break;
case '':
pBinArray[ o ] |= 0x08;
break;
case '':
pBinArray[ o ] |= 0x09;
break;
case 'A':
case 'a':
pBinArray[ o ] |= 0x0a;
break;
case 'B':
case 'b':
pBinArray[ o ] |= 0x0b;
break;
case 'C':
case 'c':
pBinArray[ o ] |= 0x0c;
break;
case 'D':
case 'd':
pBinArray[ o ] |= 0x0d;
break;
case 'E':
case 'e':
pBinArray[ o ] |= 0x0e;
break;
case 'F':
case 'f':
pBinArray[ o ] |= 0x0f;
break;
default:
return -;
} i += ;
o++;
} return o;
}
how convert large HEX string to binary array ?的更多相关文章
- How to convert a byte to its binary string representation
How to convert a byte to its binary string representation For example, the bits in a byte B are 1000 ...
- c++ hex string array 转换 串口常用
c++ hex string array 转换 效果如下 tset string is follow 0x50 55 0x35 00 10 203040506073031323334ff format ...
- Convert string to binary and binary to string in C#
String to binary method: public static string StringToBinary(string data) { StringBuilder sb = new S ...
- Java – How to convert String to Char Array
Java – How to convert String to Char ArrayIn Java, you can use String.toCharArray() to convert a Str ...
- how to convert a number to a number array in javascript without convert number to a string
how to convert a number to a number array in javascript without convert number to a string 如何在不将数字转换 ...
- itoa : Convert integer to string
Quote from: http://www.cplusplus.com/reference/cstdlib/itoa/ function Required header : <s ...
- Swift3 - String 字符串、Array 数组、Dictionary 字典的使用
Swift相关知识,本随笔为 字符串.数组.字典的简单使用,有理解.使用错误的地方望能指正. ///************************************************** ...
- How to: Convert Between Various String Types
This topic demonstrates how to convert various Visual C++ string types into other strings. The str ...
- Matlab一个错误引发的血案:??? Error using ==> str2num Requires string or character array input.
Matlab总遇到一些神奇的问题,让人摸不着头脑.昨天编写程序的时候遇到一个让我十分火大的问题,也是自己的matlab基础不好吧. 先描述一下问题,再GUI界面有个listbox,Tag属性是’lis ...
随机推荐
- MongoDB 之 $关键字 及 $修改器 $set $inc $push $pull $pop MongoDB - 4
我们在之前的 MongoDB 之 手把手教你增删改查 MongoDB - 2 中提到过 $set 这个系统关键字,用来修改值的对吧 但是MongoDB中类似这样的关键字有很多, $lt $gt $lt ...
- [MySQL 5.6] GTID实现、运维变化及存在的bug
[MySQL 5.6] GTID实现.运维变化及存在的bug http://www.tuicool.com/articles/NjqQju 由于之前没太多深入关注gtid,这里给自己补补课,本文是我看 ...
- (P2022 有趣的数)||(zoj Little Sub and Mr.Potato's Math Problem)(思维)
题目链接:https://www.luogu.org/problemnew/show/P2022 题目大意:中文题目 具体思路: 第一步:我们可以先计算出当前的数前面按照字典序的话,前面有多少数(包括 ...
- 【驱动】input子系统整体流程全面分析(触摸屏驱动为例)【转】
转自:http://www.cnblogs.com/lcw/p/3294356.html input输入子系统整体流程 input子系统在内核中的实现,包括输入子系统(Input Core),事件处理 ...
- MySQL binlog导入失败
一个同事问我,说他用innobackupex恢复数据后用mysqlbinlog导入增量数据时,发现数据没有导入进去并且也没有报错. mysqlbinlog /u01/mysql_py/database ...
- XShell 使用方法
XShell是一款Windows下非常优秀的远程连接Linux主机的工具,是平常使用不可缺少的工具.复制和粘贴由于在linux的Shell下,Ctrl+c是中断当前指令,这个快捷键和win系统下的复制 ...
- POJ 3281 Dining(最大流+拆点)
题目链接:http://poj.org/problem?id=3281 题目大意:农夫为他的 N (1 ≤ N ≤ 100) 牛准备了 F (1 ≤ F ≤ 100)种食物和 D (1 ≤ D ≤ 1 ...
- HttpUrlConnection的setDoOutput与setDoInput的区别
httpUrlConnection.setDoOutput(true) httpUrlConnection.setDoInput(true) 这两个方法在develope的httpUrlConnect ...
- Cname与A记录(Address)区别
Cname与A记录(Address)区别A记录是解析域名到IP,Cname是解析域名到另外一个域名. 一台服务器可以布置多个网站,也可以有多个域名,如如域名A----->A记录-----> ...
- Redux 和 ngrx 创建更佳的 Angular 2
Redux 和 ngrx 创建更佳的 Angular 2 翻译:使用 Redux 和 ngrx 创建更佳的 Angular 2 原文地址:http://onehungrymind.com/build- ...