Base Conversion With Strings Introduction
We've have a few base conversion challenges here in the past, but not many designed to tackle arbitrary length numbers (that is to say, numbers that are long enough that they overflow the integer datatype), and of those, most felt a little complicated. I'm curious how golfed down a change of base code like this can get.
Challenge
Write a program or function in the language of your choice that can convert a string of one base to a string of another base. Input should be the number to be converted (string), from-base (base-10 number), to-base (base-10 number), and the character set (string). Output should be the converted number (string).
Some further details and rules are as follows:

The number to be converted will be a non-negative integer (since - and . may be in the character set). So too will be the output.
Leading zeroes (the first character in the character set) should be trimmed. If the result is zero, a single zero digit should remain.
The minimum supported base range is from 2 to 95, consisting of the printable ascii characters.
The input for the number to be converted, the character set, and the output must all be of the string datatype. The bases must be of the base-10 integer datatype (or integer floats).
The length of the input number string can be very large. It's hard to quantify a sensible minimum, but expect it to be able to handle at least 1000 characters, and complete 100 characters input in less than 10 seconds on a decent machine (very generous for this sort of problem, but I don't want speed to be the focus).
You cannot use built in change-of-base functions.
The character set input can be in any arrangement, not just the typical 0-9a-z...etc.
Assume that only valid input will be used. Don't worry about error handling.

The winner will be determined by the shortest code that accomplishes the criteria. They will be selected in at least 7 base-10 days, or if/when there have been enough submissions. In the event of a tie, the code that runs faster will be the winner. If close enough in speed/performance, the answer that came earlier wins.
Examples
Here's a few examples of input and output that your code should be able to handle:
F(&quot;1010101&quot;, 2, 10, &quot;0123456789&quot;)
&gt; 85

F(&quot;0001010101&quot;, 2, 10, &quot;0123456789&quot;)
&gt; 85

F(&quot;85&quot;, 10, 2, &quot;0123456789&quot;)
&gt; 1010101

F(&quot;1010101&quot;, 10, 2, &quot;0123456789&quot;)
&gt; 11110110100110110101

F(&quot;bababab&quot;, 2, 10, &quot;abcdefghij&quot;)
&gt; if

F(&quot;10&quot;, 3, 2, &quot;0123456789&quot;)
&gt; 11

F(&quot;&lt;('.'&lt;)(v'.'v)(&gt;'.'&gt;)(^'.'^)&quot;, 31, 2, &quot;~!@#$%^v&amp;*()_+-=`[]{}|';:,./&lt;&gt;? &quot;)
&gt; !!~~~~~~~!!!~!~~!!!!!!!!!~~!!~!!!!!!~~!~!~!!!~!~!~!!~~!!!~!~~!!~!!~~!~!!~~!!~!~!!!~~~~!!!!!!!!!!!!~!!~!~!~~~~!~~~~!~~~~~!~~!!~~~!~!~!!!~!~~

F(&quot;~~~~~~~~~~&quot;, 31, 2, &quot;~!@#$%^v&amp;*()_+-=`[]{}|';:,./&lt;&gt;? &quot;)
&gt; ~

F(&quot;9876543210123456789&quot;, 10, 36, &quot;0123456789abcdefghijklmnopqrstuvwxyz&quot;)
&gt; 231ceddo6msr9

F(&quot;ALLYOURBASEAREBELONGTOUS&quot;, 62, 10, &quot;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ&quot;)
&gt; 6173180047113843154028210391227718305282902

F(&quot;howmuchwoodcouldawoodchuckchuckifawoodchuckcouldchuckwood&quot;, 36, 95, &quot;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&amp;*()_-+=[{]}\\|;:'\&quot;,&lt;.&gt;/? &quot;)
&gt; o3K9e(r_lgal0$;?w0[`&lt;$n~&lt;/SUk(r#9W@.&quot;0&amp;}_2?[n

F(&quot;1100111100011010101010101011001111011010101101001111101000000001010010100101111110000010001001111100000001011000000001001101110101&quot;, 2, 95, &quot;0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~`!@#$%^&amp;*()_-+=[{]}\\|;:'\&quot;,&lt;.&gt;/? &quot;)
&gt; this is much shorter
Python 2, 115 114 106 105 94 bytes



Golfing suggestions welcome. Try it online!

Edit: -9 bytes thanks to mbomb007. -2 bytes thanks to FlipTack.

def a(n,f,t,d,z=0,s=''):
 for i in n:z=z*f+d.find(i)
 while z:s=d[z%t]+s;z/=t
 print s or d[0]


Ungolfed:

def arbitrary_base_conversion(num, b_from, b_to, digs, z=0, s=''):
    for i in num:
        z = z * b_from + digs.index(i)
    while z:
        s = digs[z % b_to] + s
        z = z / t
    if s:
        return s
    else:
        return d[0]