Why/how function string.Substring treats "\u0002" as a one sign? I mean ok, "\u0002" is a "character" STX.
- \u says that is unicode
- Character and string processing in C# uses Unicode encoding. The char type represents a UTF-16 code unit, and the string type represents a sequence of UTF-16 code units.
Code checks if prefix and suffix are correct. Data length does not matter.
Prefix is STX , suffix is ETX added do data string.
How to do this(code below) explicitly without a doubt?
string stx = "\u0002";
string etx = "\u0003";
string ReceivedData= stx + "1122334455" + etx;
string prefix = ReceivedData.Substring(0, 1);
string suffix = ReceivedData.Substring(ReceivedData.Length - 1, 1);