use chardet instead of guessing