Additionally, I did run into a problem using the + modifier in sprintf(): while the resulting string is encoded as signed, it prepends a +, which seems incorrect to me, such that it's not possible to decode without first removing the +:
array_sscanf(sprintf("%-+4c", -65335), "%-+4c"); (16) Result: ({ /* 1 element */ -16725717 })
While prepending the + seems a bit pointless, that's what + does in sprintf. You don't need to add it to get a "signed" binary number:
array_sscanf(sprintf("%-4c", -65335), "%-+4c");
(2) Result: ({ /* 1 element */ -65335 })