I think my previous comment was a complicated monstrosity,
and completely failed to take into account user defined types. Here is a
much simpler (if a bit more verbose version), that (I think) completely
takes everything into account:

```D
        //Non-variable encodings
        static if (is(Dst == dchar) || is(Dst == AsciiChar) || is(Dst ==Latin1Char) || is(Dst == Windows1252Char))
        {
            immutable bufferLength = s.length;
        }
        else static if (is(Dst == wchar))
        {
            static if (is(Src == char) || is(Src == wchar) || is(Dst ==AsciiChar) || is(Dst == Latin1Char) || is(Dst == Windows1252Char))
                immutable bufferLength = s.length;
            else //dchar and everything else
                immutable bufferLength = 2 * s.length;
        }
        else static if (is(Dst == char))
        {
            static if (is(Src == char) || is(Src == AsciiChar))
                immutable bufferLength = 1 * s.length;
            static if (is(Src == wchar) || is(Dst == Latin1Char) || is(Dst == Windows1252Char))
                immutable bufferLength = 3 * s.length;
            else //dchar and everything else
                immutable bufferLength = 4 * s.length;
        }
        else//Everything else (user defined types)
            immutable bufferLength = 4 * s.length; //(is 4 enough for *any* user defined type? Maybe 6?)
```