What are the problems of a zero-terminated string that length-prefixed strings overcome?

后端 未结 6 1772
滥情空心
滥情空心 2021-02-06 21:57

What are the problems of a zero-terminated string that length-prefixed strings overcome?

I was reading the book Write Great Code vol. 1 and I had that question in mind.<

6条回答
  •  独厮守ぢ
    2021-02-06 22:29

    One problem is that you can not store null characters (value zero) in a zero terminated string. This makes it impossible to store some character encodings as well as encrypted data.

    Length-prefixed strings do not suffer that limitation.

提交回复
热议问题