':yield: A series of 4-tuples.
(markup, encoding, declared encoding,
has undergone character replacement)
Each 4-tuple represents a strategy for parsing the document.'

def prepare_markup(self, markup, user_specified_encoding=None, exclude_encodings=None, document_declared_encoding=None):

    if isinstance(markup, unicode):
        (yield (markup, None, document_declared_encoding, False))
    if isinstance(markup, unicode):
        (yield (markup.encode('utf8'), 'utf8', document_declared_encoding, False))
    is_html = (not self.is_xml)
    try_encodings = [user_specified_encoding, document_declared_encoding]
    detector = EncodingDetector(markup, try_encodings, is_html, exclude_encodings)
    for encoding in detector.encodings:
        (yield (detector.markup, encoding, document_declared_encoding, False))
