当前位置:网站首页>Hexadecimal to string
Hexadecimal to string
2022-07-29 02:19:00 【Mubai 001】
// Two 16 Hexadecimal characters are converted to one byte
int IsLowercase(signed int character)
{
int result;
result = character >= 'a' && character < '{';
return result;
}
int UpperCaseToLower(int Character)
{
if ( IsLowercase(Character) )
Character -= 32;
return Character;
}
// Here is the fixed input of even characters 16 Hexadecimal characters
void StrToHex(uint8_t *HexStr, uint8_t *HexNum,int hexCount)
{
uint8_t *tHexStr; // r7
uint8_t *tHexNum; // r4
signed int Count; // r6
int HexResult; // r8
char LowCaseCharacter; // r0
char tCount; // r0
int i = hexCount;
tHexStr = HexStr;
tHexNum = HexNum;
Count = 0;
HexResult = 0;
while ( Count < i && *tHexStr )
{
LowCaseCharacter = UpperCaseToLower((char)*tHexStr++);
// Judge non numbers
if ( LowCaseCharacter < 0x30 || LowCaseCharacter >= 0x3A ) {
if ( LowCaseCharacter < 'A' || LowCaseCharacter >= 'G' )// If not A-F Between the character values Then exit by mistake
{
//printf((int)"key must be in hexadecimal notation\n");
return;
}
HexResult = LowCaseCharacter + 16 * HexResult - 0x37;// If it is A-F The number in
}else {
HexResult = LowCaseCharacter + 16 * HexResult - 0x30;// If it's a number
}
tCount = Count++;
if ( tCount & 1 ) // If the current reading is an odd number Then it is not stored in the array If it's an even number Just put the two together in the array
tHexNum[Count / 2 - 1] = HexResult;
}
}
void HexToAscii(uint8_t *pHex, uint8_t *pAscii, int nLen)
{
unsigned char Nibble[2];
unsigned int i,j;
for (i = 0; i < nLen; i++){
Nibble[0] = (pHex[i] & 0xF0) >> 4;
Nibble[1] = pHex[i] & 0x0F;
for (j = 0; j < 2; j++){
if (Nibble[j] < 10){
Nibble[j] += 0x30;
}
else{
if (Nibble[j] < 16)
Nibble[j] = Nibble[j] - 10 + 'A';
}
*pAscii++ = Nibble[j];
}
}
}
边栏推荐
- Establish an engineering template based on STM32 in keil -- detailed steps
- Excel 用countif 统计
- 12. < tag dynamic programming and subsequence, subarray> lt.72. edit distance
- Leetcode/ and continuous shortest subarray greater than or equal to target
- 基于C51控制蜂鸣器
- Complete collection of common error handling in MySQL installation
- JetPack--Navigation实现页面跳转
- 开启TLS加密的Proftpd安全FTP服务器安装指南
- Verilog procedure assignment statements: blocking & non blocking
- Navigation--实现Fragment之间数据传递和数据共享
猜你喜欢

STM32 DMA receives serial port data
![[circuit design] convert AC AC to DC](/img/b4/67df7f4555379c63694e89055499bb.jpg)
[circuit design] convert AC AC to DC

Type analysis of demultiplexer (demultiplexer)

Flexible layout single selection

Mathematical modeling -- the laying of water pipes

一文读懂Okaleido Tiger近期动态,挖掘背后价值与潜力
![[electronic components] constant voltage, amplify the current of the load (triode knowledge summary)](/img/07/d5861404a76a0fb7d6d5f930a4a66a.png)
[electronic components] constant voltage, amplify the current of the load (triode knowledge summary)

Cookie和Session
[electronic components] zener diode
![[circuit design] open collector OC output of triode](/img/48/5a111b81f0d99990fbcc5263313c07.jpg)
[circuit design] open collector OC output of triode
随机推荐
在Qt中如何编写插件,加载插件和卸载插件
发布融资需求1.29亿元,大科城项目路演持续浇灌科创“好苗子”
【ONE·Data || 链式二叉树】
Click back to the top JS
指针——黄金阶段
Idea connection database
进程间通信---对管道的详细讲解(图文案例讲解)
Anti crawler mechanism solution: JS code generates random strings locally
Using local cache + global cache to realize user rights management of small systems
PS + PL heterogeneous multicore case development manual for Ti C6000 tms320c6678 DSP + zynq-7045 (2)
2022.7.28-----leetcode.1331
Blind separation of speech signals based on ICA and DL
Ciscn 2022 central China Misc
表单校验 隐藏的输入框 显示才校验
autoware中ndtmatching功能加载点云图坐标系修正的问题
Type analysis of demultiplexer (demultiplexer)
Comprehensive use method of C treeview control
2022.7.28-----leetcode.1331
Read the recent trends of okaleido tiger and tap the value and potential behind it
Rgbd point cloud down sampling