Gulliver didn’t know what to say. Gulliver didn’t know how to get away.
Use a question word with a to-infinitive after a verb.