Closes #106: Fix encoding detection bug