Handle null enconding. Closes #1955.