Emulates PHP finfo extesion. Reads file magic headers and has internal charset detection.