Split encoding from charset

Closes #983