Why does url decode not get an error when it decodes %22. This is a double quote. When a programmer enters a double quote in a string syntactically they must use two double quotes "" to represent a double quote.
For Example
string myString = "It\"s nice to meet you";
console.write(myString);
Output
It"s nice to meet you
But when url decodes a double quotes why does it not break. After the string is passed through the url decoder there is only a single quote ". Why does this not break the code?
For Example
string myString = "It%22s nice to meet you";
myString = HttpUtility.UrlDecode(myString);
console.Write(myString);
Output
It"s nice to meet you
The need to escape double quotes is only a concern for literal strings in C#. The language is defined that way. Non-literals are not impacted: ((char)35).ToString() == "\""
is true.
This has no impact on the actual runtime values. "\"".Length
is 1. The CLR is not aware of the escaping.
The CLR is capable of hosting many programming languages. It does not care about the escaping rules of a single language.
Library functions cannot even tell how you wrote or computed a string. Even if they wanted to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With