Skip to content

Instantly share code, notes, and snippets.

@AndreiCherniaev
Last active June 1, 2023 02:15
Show Gist options
  • Save AndreiCherniaev/9088c5d09aa6cc630ae7fbbe705fe7d8 to your computer and use it in GitHub Desktop.
Save AndreiCherniaev/9088c5d09aa6cc630ae7fbbe705fe7d8 to your computer and use it in GitHub Desktop.
text to uint8_t
#include <stdio.h>
#include <stdint.h>
#include <string.h>
int main()
{
char str[] = {"43074401014501014601014701014807314900044A004B019303FC07E7080C07F203DA087802E34C01014C756D69722D54312043756265536174202F2044657369676E6564206279204C756D69722853656F2053616E4A756E2C4C6565204A756E2C5061726B204A756E546165292020202020202020202020202020000020C24D"};
if(strlen(str) % 2 == 0){
printf("uint8_t arr[%lu]= { 0x", strlen(str)/2);
uint32_t i=0;
uint32_t j=0;
while(i<strlen(str)){
printf("%c", str[i]);
if((i % 2 == 1) && (i!= strlen(str)-1)) printf(", 0x");
i++;
}
}
printf("};");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment