Answer the question
In order to leave comments, you need to log in
What byte to use?
I have a slice with bytes. I need to break it into parts (I don't know how long one or the other part is). It is obvious that it is necessary to use some byte as a separator. I am writing here because I don’t know which byte will not be found in a 100% slice. It contains characters in any possible encoding.
Answer the question
In order to leave comments, you need to log in
Any byte can meet. Better use int as the length of a piece of string, or some ready-made data exchange format like JSON or protobuf.
Another option, stupid, of course, but still.
The first byte will be the delimiter. Before splitting, you can check that there is no such byte. Counted the first byte, truncated the slice, looking for the delimiter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question