Encode/Decode unicode characters in cmd.run states (2014.1 branch)

Fixes #13878.