detects the format of a given buffer or string