分隔二进制序列 [英] Delimiting binary sequences
本文介绍了分隔二进制序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要能够分隔二进制数据流.我正在考虑使用诸如 ASCII EOT(传输结束)字符之类的东西来执行此操作.
I need to be able to delimit a stream of binary data. I was thinking of using something like the ASCII EOT (End of Transmission) character to do this.
但是我有点担心——我怎么能确定用于此的特定二进制序列 (0b00000100) 不会出现在我自己的二进制序列中,从而在定界时给出误报?
However I'm a bit concerned -- how can I know for sure that the particular binary sequence used for this (0b00000100) won't appear in my own binary sequences, thus giving a false positive on delimitation?
换句话说,如何最好地处理二进制定界?
In other words, how is binary delimiting best handled?
...不使用长度标题.对不起,伙计们,之前应该提过这个的.
...Without using a length header. Sorry guys, should have mentioned this before.
推荐答案
你有五个选择:
- 使用不太可能出现的分隔符.这冒着你猜错的风险.我不推荐这种方法.
- 使用分隔符和转义序列来包含分隔符.您可能需要将转义字符加倍,具体取决于使解析更容易的原因.(想想 C