do a backport of r75928

The added test does not fail without the patch, but we still fix the issue of
surrogates being used in wide builds where they should not be.
2 files changed