V
V
Vladimir Grabko2016-08-06 09:22:03
go
Vladimir Grabko, 2016-08-06 09:22:03

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

2 answer(s)
A
Alexander Pavlyuk, 2016-08-06
@VGrabko

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.

E
Evgeniy Ivakha, 2016-08-11
@ivahaev

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 question

Ask a Question

731 491 924 answers to any question