Simple scripts to convert string (utf8) to uint8/uint32/uint64 arrays for stack string usage.
Python version also available.
Usage:
# `--bits` is optional. defaults to `32`
# `--array_name` is optional. defaults to `array_str`
# Input also accepts text file that ends with `.txt`
# python3 main.py "input file.txt" --bits 64 --array_name array_str
python3 main.py "Input string here." --bits 64 --array_name array_str
Input string: Input string here.
// auto generated by char to u8. please don't edit this manually.
// string length (18)
// Input string here.
uint8_t array_str[19];
array_str[0] = 0x49;
array_str[1] = 0x6e;
array_str[2] = 0x70;
array_str[3] = 0x75;
array_str[4] = 0x74;
array_str[5] = 0x20;
array_str[6] = 0x73;
array_str[7] = 0x74;
array_str[8] = 0x72;
array_str[9] = 0x69;
array_str[10] = 0x6e;
array_str[11] = 0x67;
array_str[12] = 0x20;
array_str[13] = 0x68;
array_str[14] = 0x65;
array_str[15] = 0x72;
array_str[16] = 0x65;
array_str[17] = 0x2e;
array_str[18] = 0x0;
// auto generated by char to u32. please don't edit this manually.
// string length (18)
// Input string here.
uint32_t array_str[5];
array_str[0] = 0x75706e49;
array_str[1] = 0x74732074;
array_str[2] = 0x676e6972;
array_str[3] = 0x72656820;
array_str[4] = 0x2e65;
// auto generated by char to u64. please don't edit this manually.
// string length (18)
// Input string here.
uint64_t array_str[3];
array_str[0] = 0x7473207475706e49;
array_str[1] = 0x72656820676e6972;
array_str[2] = 0x2e65;