encoding function

detect the encoding of texts