Support multiencoding

Encoding was hardcoded as 'gbk' instead of variable settings.encoding. Added fix for it.