code: def utf8(value):
      r
      try:
          if isinstance(value, bytes):
              return value.decode('utf-8')
          else:
              return value
      except Exception:
          raise ValueError('Not UTF-8: %r' % value)
docs: r"""
      Check that the string is UTF-8. Returns an encode bytestring.
  
      >>> utf8(b'\xe0')  # doctest: +ELLIPSIS
      Traceback (most recent call last):
      ...
      ValueError: Not UTF-8: ...