Fix #20 add encoding detection