Encode/Decode unicode characters in cmd.run states

Fixes #13878.