Merge pull request #3716 from b4n/encodings-fixes