inputs/base: Copy the codec's charset when switching.

Includes tests