Is there a reason you can't do printf("%.*s", strlen, strptr); ?
E.g., take the JSON:
"\"\uD83D\uDCA9\""
There's no (pointer, length) into that that you can then printf(…, ptr, len); you'd get the escapes, raw.Ofc., there might be situations like debugging where that's fine.
#include <stdio.h>
void main()
{
char buff[10] = {'R', 'o', 'b', 'o', 't', 't', 'y', 'p', 'e', 's'};
printf("=>%.*s<=", 4, ((char *)&buff + 3));
}
prints =>otty<= all the “tokens” are given as byte offsets and lengths