def _utf8(s):
    """encode a unicode string as utf-8"""
    if isinstance(s, unicode):
        return s.encode("utf-8")
    assert isinstance(s, str), "_utf8 expected a str, not %r" % type(s)
    return s
dataset/ETHPy150Open nsqio/pynsq/nsq/reader.py/_utf8/original