Text this: Optimal quantum circuits for general phase estimation