Setting encoding
Upstream changes from hg