def remove_unneeded_characters(input_string, encoding='utf-8', char_classes_to_remove=["C", "M", "P", "S", "Z"]):
    input_was_unicode = True
    if isinstance(input_string, basestring):
        if not isinstance(input_string, unicode):
            input_was_unicode = False

    unicode_input = to_unicode_or_bust(input_string)

    response = u''.join(c for c in unicode_input if unicodedata.category(c)[0] not in char_classes_to_remove)

    if not input_was_unicode:
        response = response.encode(encoding)
        
    return response



# derived from the jsonp function in bibserver
dataset/ETHPy150Open Impactstory/total-impact-webapp/util.py/remove_unneeded_characters/original