Glad you have a solution, and Thank You for posting the discovery - am sure it will help the next curious coder that finds this thread.
Copy & pasted the two functions h2int() and urldecode() into my sketch and they work!
Did you consider a simple replace function like below for 0%2C255%2C128 to 0,255,128?
// zoomkat 7-30-11 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later
String readString;
void setup() {
Serial.begin(9600);
Serial.println("serial test 0021"); // so I can keep track of what is loaded
}
void loop() {
while (Serial.available()) {
delay(2); //delay to allow byte to arrive in input buffer
char c = Serial.read();
readString += c;
}
if (readString.length() >0) {
Serial.println(readString);
readString.replace("%2C", ",");
Serial.println(readString);
Serial.println();
readString="";
}
}
Hello.
I have a small correction for the hex_digit function bellow.
The '0' between '9' and 'A' should not be there.
return "01234567890ABCDEF"[c & 0x0F];
Old thread but I just found it today, used it and got a weird output.
Original:
static char hex_digit(c)
{ return "01234567890ABCDEF"[c & 0x0F];
}
Correct:
static char hex_digit(c)
{ return "0123456789ABCDEF"[c & 0x0F];
}
1 Like