Implement SV-based write_string and string_size

This makes the next changeset (sections) less tedious.