Is not really elegant. If you just need to initialize an array statically then just do it like I said in my previous response. If you want to convert a string dynamically (example: string coming from serial) to an array of values then strtol will work fine.
Show me an example of its use, from any source code you like. One thing that puzzles me about it, if it's from a form, I guess you have control over the format. Why would you use an obscure C language based format for that? How is the data generated in the first place? By a machine? Human? Normally you would use CSV format or similar for something like that.
Also, that code has unnecessary conversions. I'm pretty sure you can read the data directly into a c string (array) and process it directly from there...
Also the String class can cause problems if used indiscriminately on some Arduinos with small memory footprints.
Do you want to see "AABBCCDD" as AA BB CC DD (the separate hex bytes)? The following sketch saves them in the array named: byteArray[].
void setup()
{
Serial.begin(9600);
char data[] = "AABBCCDD";
unsigned long x = strtoul(data, NULL, 16);
//Serial.println(x, HEX);//AABBCCDD
int i = 0;
byte byteArray[4];
do
{
byteArray[i] = x % 0x100;
x = x / 0x100;
i++;
}
while (x != 0);
for (int k = 3; k >= 0; k--)
{
Serial.println(byteArray[k], HEX);
}
}
void loop()
{
}