docs: def _decode(rawstr):
      """Convert a raw string to a Message.
      """
      # Check for the magick word.
      try:
          rawstr = rawstr.decode('utf-8')
      except (AttributeError, UnicodeEncodeError):
          pass
      except (UnicodeDecodeError):
          try:
              rawstr = rawstr.decode('iso-8859-1')
          except (UnicodeDecodeError):
              rawstr = rawstr.decode('utf-8', 'ignore')
      if not rawstr.startswith(_MAGICK):
          raise MessageError("This is not a '%s' message (wrong magick word)"
                             % _MAGICK)
      rawstr = rawstr[len(_MAGICK):]
  
      # Check for element count and version
      raw = re.split(r"\s+", rawstr, maxsplit=6)
      if len(raw) < 5:
          raise MessageError("Could node decode raw string: '%s ...'"
                             % str(rawstr[:36]))
      version = raw[4][:len(_VERSION)]
      if not _is_valid_version(version):
          raise MessageError("Invalid Message version: '%s'" % str(version))
  
      # Start to build message
      msg = dict((('subject', raw[0].strip()),
                  ('type', raw[1].strip()),
                  ('sender', raw[2].strip()),
                  ('time', strp_isoformat(raw[3].strip())),
                  ('version', version)))
  
      # Data part
      try:
          mimetype = raw[5].lower()
          data = raw[6]
      except IndexError:
          mimetype = None
  
      if mimetype is None:
          msg['data'] = ''
          msg['binary'] = False
      elif mimetype == 'application/json':
          try:
              msg['data'] = json.loads(raw[6], object_hook=datetime_decoder)
              msg['binary'] = False
          except ValueError:
              raise MessageError("JSON decode failed on '%s ...'" % raw[6][:36])
      elif mimetype == 'text/ascii':
          msg['data'] = str(data)
          msg['binary'] = False
      elif mimetype == 'binary/octet-stream':
          msg['data'] = data
          msg['binary'] = True
      else:
          raise MessageError("Unknown mime-type '%s'" % mimetype)
  
      return msg