In this blog post, I would like to tackle a recurring phenomenon that I always solved via trial-and-error, depending on the machine I was working on. I think it’s time to get a conclusive answer to the single/double quote problem that occurs with cURL in de Windows Command Prompt.
The issue usually manifests itself in the following way. You copy a cURL request command from a particular source. You expect it to work, but the error you receive hints that the https protocol is not supported.
However, if you look closely, you see a single quote between the double quotes in the error line. This is the character that results in the error. Consequently, if you replace every single quote in the request with a double quote, the call will succeed. What is going on here?
Single quotes in the command prompt
The Windows Command Prompt (CMD) cannot process single quotes, except for a particular situation: to loop over the results of a command.
FOR /F ["options"] %%parameter IN ('command to process') DO command
For this reason, you should never use single quotes in a command in CMD.
- To turn on quoting in CMD by typing a double quote. End quoting by typing another double quote.
- Basically, all characters are treated as literals within the double-quotes (except % and ! in some circumstances).
- You can escape double quotes (outside quoting) by putting a ^ in front of it, like this: ^”.
On a final note, you can use a unicode encoded single quote.