improve fileencoding detection