I started seeing strange characters like this...
got code >���?␟<
...printing out in my serial monitor when using this code...
Serial.printf("got code >%s<\n", code);
This was despite my unit tests telling me that the (Arduino) String code actually contained printable characters (alpha-numerics and simple punctuation).
It wasn't happening for all my printf statements, but would consistently happen with the same ones.
The problem went away when I broke
Serial.printfinto a series ofSerial.printstatements, e.g.I still haven't figured out why, unfortunately, but I hope this saves you some time.