[1.6.x] Fixed #21269 -- Don't crash when CommandError contains non-ascii

Thanks kontakt@eikefoken.de for the report.

Backport of 42a67ec1cd from master.