Why/how function string.Substring treats "\" as a one sign? I mean ok, "\" is a "character" STX.
Code checks if preffix suffics is 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);
Do you wonder the working mechanism of UTF-16 and Unicode? May this topic helps: What is Unicode, UTF-8, UTF-16?
The code snippet looks reasonable as the variables are explicitly named and '\\u\u0026#39; is a sign of Unicode.
string stx = "\u0002";
string etx = "\u0003";
string prefix = ReceivedData.Substring(0, 1);
string suffix = ReceivedData.Substring(ReceivedData.Length - 1, 1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.