为什么/如何函数string.Substring将"\u0002“视为一个符号?我是说,"\u0002“是个”人物“STX。
unicode
代码检查前缀是否正确。数据长度并不重要。前缀是STX,后缀是ETX添加的do数据字符串。毫无疑问,如何做到这一点(下面的代码)?
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);
发布于 2021-04-17 14:26:52
你想知道UTF-16和Unicode的工作机制吗?愿本主题有所帮助:What is Unicode, UTF-8, UTF-16?
代码段看起来很合理,因为变量是显式命名的,'\u‘是Unicode的标志。
string stx = "\u0002";
string etx = "\u0003";
string prefix = ReceivedData.Substring(0, 1);
string suffix = ReceivedData.Substring(ReceivedData.Length - 1, 1);
https://stackoverflow.com/questions/67138855
复制相似问题