Format string utility function.