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 ...
随机推荐
- SQLSTATE[42000]
SQLSTATE[42000]: Syntax error or access violation: 1140 Mixing of GROUP columns (MIN(),MAX(),COUNT() ...
- 第5月第16天 php crud CodeIgniter CI_DB_active_record
1.C.R.U.D. Generator for CodeIgniter https://github.com/antonioyee/crud-generator/tree/9e5e48e773a52 ...
- 第7月第12天 opengles background
1. After your app exits its applicationDidEnterBackground: method, it must not make any new OpenGL E ...
- JAVA中Collection接口和Map接口的主要实现类
Collection接口 Collection是最基本的集合接口,一个Collection代表一组Object,即Collection的元素(Elements).一些Collection允许相同的元素 ...
- oracle 学习day01
1.关系型数据库的设计范式 范式:是关系型数据库关系模型规范化的标准.范式是建立在函数依赖的基础上. 函数依赖:如果表中某一个字段Y的值是有另外一个字段或一组字段X的值来确定,就称作Y函数 ...
- fish(自动推荐命令;语法高亮等)
Fish 是 Linux/Unix/Mac OS 的一个命令行 shell,有一些很好用的功能. 自动推荐 VGA 颜色 完美的脚本支持 基于网页的配置 帮助文档自动补全 语法高亮 以及更多 自动推荐 ...
- Mysql导入脚本失败,提示需要SUPER权限
1.删除: /*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */ 2.查看增删函数有没有重复 3.删除: set GLOBAL log ...
- 浅介HTML DOM
什么是DOM? DOM是Document Object Model(文档对象模型)的缩写. DOM是W3C(万维网联盟)的标准. DOM定义了访问HTML和XML文档的标准: “W3C文档对象模型(D ...
- Scala工具库
1. Scala json解析库:https://github.com/json4s/json4s
- CentOS 7安装图形化界面后重启出现Initial setup of CentOS Linux 7 (core)
这是CentOS内核的初始设置页面,下面给出中文解释及操作方法. 1.CentOS Linux 7 初始设置(核心) 1)[!]许可证信息 (没有接受许可证) 请您选择[‘1’ 输入许可证信息 | ‘ ...