Minor enhancements to character encoding handling.