Fix for unicode environment variable handling

Fixes #5395