Account for ^@ because for some reason COLOR_* skips it. Also, fix a case where the pointer can go past the boundaries of the input string corrupting output.