def normalize_string(value):
    """ Normalize a string value. """
    if isinstance(value, bytes):
        value = value.decode()
    if isinstance(value, str):
        return value.strip()
    raise ValueError("Cannot convert {} to string".format(value))