def StringSizer(field_number, is_repeated, is_packed):
tag_size = _TagSize(field_number)<EOL>local_VarintSize = _VarintSize<EOL>local_len = len<EOL>assert not is_packed<EOL>if is_repeated:<EOL><INDENT>def RepeatedFieldSize(value):<EOL><INDENT>result = tag_size * len(value)<EOL>for element in value:<EOL><INDENT>l = local_len(element.encode('<STR_LIT:utf-8>'))<EOL>result += local_VarintSize(l) + l<EOL><DEDENT>return result<EOL><DEDENT>return RepeatedFieldSize<EOL><DEDENT>else:<EOL><INDENT>def FieldSize(value):<EOL><INDENT>l = local_len(value.encode('<STR_LIT:utf-8>'))<EOL>return tag_size + local_VarintSize(l) + l<EOL><DEDENT>return FieldSize<EOL><DEDENT>
Returns a sizer for a string field.