Detect system encoding

For Windows support