def crop(text, width=_DEFAULT_WIDTH, suffix="[...]"):

    utext = to_unicode(text)
    ltext = len(utext)
    if ltext <= width:
        return text
    else:
        lsuffix = len(suffix)
        utext = utext[:width] if lsuffix >= width else "%s%s" % (utext[:width - lsuffix], suffix)
        return to_str(utext)
Crop text to a certain width, throwing away text from too-long
dataset/ETHPy150Open evennia/evennia/evennia/utils/utils.py/crop