Fixes #5421 fixes some encoding issues where wrong context was used