def get_charset(response, default='utf-8'):
    """Return encoding."""
    try:
        return response.info().get_param('charset', default)
    except AttributeError:
        content_type = response.headers['content-type']
        split_on = 'charset='
        if split_on in content_type:
            return content_type.split(split_on)[-1]
        else:
            return default
