hi,
I have a byte array (UTF-8 encoded string send as byte array from client). The message should have the following format:
'number' 'timestamp' 'str1' 'str2'
E.g
1 2000-01-31T20:00.00 the 1st str the 2nd str
It is clear that the 'number' and 'timestamp' are easily read from the byte array. The start position of 'str1' can be also figured out. Considering that 'str1' and 'str2' can have any content (any length) in it, what type of delimiter can be used to know when 'str1' ends and 'str2' starts? Or are there any other tricks for parsing something like this.
note1: the message format is provided by me so any solution with a different format/order will do as long as all 4 pieces of info is in the byte array.
note2: I know I could encode str1 so that it doesn't contain my custom delimiter but I would like to avoid the overhead of encoding/decoding the data.
note3: One solution I could think of was to write the length of str1 in front of it when sending the data from client side. E.g 'number' 'timestamp' 'str1length' 'str1' 'str2'
are there any other tricks you can think of?
thanks