admin管理员组文章数量:1392047
I have a nodejs TCP server and a client. Basic network munication happens. Client sends "data + STX_CHARACTER + data + ETX_CHARACTER" (just an example).
How do I split the string using the STX Control Character as a delimiter or how do I reference the character at all in Javascript.
I have a nodejs TCP server and a client. Basic network munication happens. Client sends "data + STX_CHARACTER + data + ETX_CHARACTER" (just an example).
How do I split the string using the STX Control Character as a delimiter or how do I reference the character at all in Javascript.
Share Improve this question edited May 18, 2010 at 6:13 Justin Johnson 31.3k7 gold badges66 silver badges89 bronze badges asked May 18, 2010 at 5:16 Gio BorjeGio Borje 21.1k7 gold badges39 silver badges50 bronze badges2 Answers
Reset to default 5STX and ETX are characters 0x02 and 0x03 respectively, so it'd just be "\2" and "\3". Just use string.split("\2") and .split("\3") on the second chunk from the first split to get your data.
For example you need to split string by Control character (0x17).It is equal to Decimal 23. So you do simple this: console.log(yourString.split(String.fromCharCode(23)));
本文标签: javascriptControl characters as delimitersStack Overflow
版权声明:本文标题:javascript - Control characters as delimiters - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744782441a2624793.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论