首页 > 其他分享 >StringToByte(char* source, uint8_t* dest, int sourceLen)

StringToByte(char* source, uint8_t* dest, int sourceLen)

时间:2023-04-07 15:48:42浏览次数:29  
标签:dest StringToByte uint8 source int highByte lowByte

void StringToByte(char* source, uint8_t* dest, int sourceLen)
{
    int i;
    uint8_t highByte, lowByte;

    for (i = 0; i < sourceLen; i += 2)
    {
        highByte = toupper(source[i]);
        lowByte  = toupper(source[i + 1]);

        if (highByte > 0x39)
            highByte -= 0x37;
        else
            highByte -= 0x30;

        if (lowByte > 0x39)
            lowByte -= 0x37;
        else
            lowByte -= 0x30;

        dest[i / 2] = (highByte << 4) | lowByte;
    }
    return ;
}

 

标签:dest,StringToByte,uint8,source,int,highByte,lowByte
From: https://www.cnblogs.com/yuqilihualuo/p/17296355.html

相关文章