def base_n_to_int(string, charset):
    """Convert a base-N string into an integer using a given character set.

    :param str string: The string to convert
    :param str charset: The character set to use for the conversion
    :returns str: The converted string
    :raises ValueError: If `charset` contains duplicate characters

    """
    if len(charset) > len(set(charset)):
        raise ValueError('character set contains duplicate characters')
    base = len(charset)
    integer = 0
    for index, char in enumerate(reversed(string)):
        integer += charset.index(char) * base ** index
    return integer
