code: def decode_modified_utf8(data, errors="strict"):
      
      value, length = u"", 0
      it = iter(decoder(data))
      while True:
          try:
              value += next(it)
              length += 1
          except StopIteration:
              break
          except UnicodeDecodeError as e:
              if errors == "strict":
                  raise e
              elif errors == "ignore":
                  pass
              elif errors == "replace":
                  value += u"\uFFFD"
                  length += 1
      return value, length
docs: Decodes a sequence of bytes to a unicode text and length using
      Modified UTF-8.
      This function is designed to be used with Python ``codecs`` module.
  
      :param data: a string of bytes in Modified UTF-8
      :param errors: handle decoding errors
      :return: unicode text and length
      :raises UnicodeDecodeError: sequence is invalid.