added utility to detect encoding of an inputstream