def StringEncoder(field_number, is_repeated, is_packed):
 tag = TagBytes(field_number, wire_format.WIRETYPE_LENGTH_DELIMITED)
 local_EncodeVarint = _EncodeVarint
 local_len = len
 assert (not is_packed)
 if is_repeated:
  def EncodeRepeatedField(write, value):
   for element in value:
    encoded = element.encode('utf-8')
    write(tag)
    local_EncodeVarint(write, local_len(encoded))
    write(encoded)
  return EncodeRepeatedField
 else:
  def EncodeField(write, value):
   encoded = value.encode('utf-8')
   write(tag)
   local_EncodeVarint(write, local_len(encoded))
   return write(encoded)
  return EncodeField

def StringEncoder ( field_number , is_repeated , is_packed ) : tag = TagBytes ( field_number , wire_format . WIRETYPE_LENGTH_DELIMITED ) local_EncodeVarint = _EncodeVarint local_len = len assert ( not is_packed ) if is_repeated : def EncodeRepeatedField ( write , value ) : for element in value : encoded = element . encode ( 'utf-8' ) write ( tag ) local_EncodeVarint ( write , local_len ( encoded ) ) write ( encoded ) return EncodeRepeatedField else : def EncodeField ( write , value ) : encoded = value . encode ( 'utf-8' ) write ( tag ) local_EncodeVarint ( write , local_len ( encoded ) ) return write ( encoded ) return EncodeField
returns an encoder for a string field .