backport of #2674
Merge pull request #2871 from jerrinot/bugs/utf8-2674/maintance-3.x

backport of #2674