Use bytesize method instead of length in protocol.

Needed for correct handling of strings, which contain multibyte chars.