Handle non-ascii headers. Closes #5021.