Lengths, not delimiters
transcript
A phone receives several texts in one packet. The sender joins them with a hash. A text can hold a hash too.
Splitting the joined text on the hash gives three pieces. There were only two strings. Write the length first, then read that many characters. The hash inside is harmless.
For each string, write its length in digits. Then write one marker character. Then write the text itself, whatever it holds.
Read digits up to the first marker. Take exactly that many characters. Repeat until the packet ends.
Test an empty string. Its length is zero, and it must still decode. Test text that holds digits. Test text that holds the marker.
The length says exactly where a text stops. No character in the text is special. Even empty strings fit, with length zero. Nothing is read for them.
Never trust a delimiter. Write the length, then the text. Read exactly that many characters. Full breakdown in the lecture.