Fix deprecations.
Add character encoding parameter.