def repr_feature(feature, max_keys=100, indent=8, lexigraphic=False):
    '''
    generate a pretty-printed string for a feature

    Currently implemented:
      * StringCounter

    @max_keys: truncate long counters

    @indent: indent multi-line displays by this many spaces

    @lexigraphic: instead of sorting counters by count (default), sort
    keys lexigraphically
    '''
    if isinstance(feature, (str, bytes)):
        try:
            ustr = feature.decode('utf8')
            return ustr
        except:
            # failure to decode, not actually utf8, other binary data
            return repr(feature)

    if isinstance(feature, StringCounter):
        return repr_stringcounter(feature, max_keys, indent, lexigraphic)
    elif isinstance(feature, unicode):
        return feature
    else:
        return repr(feature)

    assert False, 'internal logic failure, no branch taken'
generate a pretty-printed string for a feature

    Currently implemented:
      * StringCounter

    @max_keys: truncate long counters

    @indent: indent multi-line displays by this many spaces

    @lexigraphic: instead of sorting counters by count (default), sort
    keys lexigraphically