Just a comment for GeoffM's answer (I don't have enough points to comment on the correct path).
You should not insert STX (or other characters) this way using only two digits.
If the next character (after "\ x02") was a valid hexadecimal digit, this would also be parsed, and that would be a mess.
string s1 = "\x02End"; string s2 = "\x02" + "End"; string s3 = "\x0002End";
Here s1 is equal to ".nd", since 2E is a dot symbol, while s2 and s3 are equal to STX + "End".
source share