How could I safely determine whether or not to URLDecode an nvarchar value?
My specific case is that I have an nvarchar(max) field in a SQL Table containing 'message' text. Some entries appear to be URLEncoded (or application/x-www-form-urlencoded link, which is similar but uses + for spaces) while others are regular text (ie. not encoded).
Is there a way to determine which entries would need to be URLDecoded?
The risk in URLDecoding everything, is text like:
The $ is +-10 times to ZAR which is between %20 and %21 cheaper. Call +27(0) 55 555 5555. T+C Apply.
would result in:
The $ is -10 times to ZAR which is between and ! cheaper. Call 27(0) 55 555 5555. T C Apply.
I suspect that a relatively safe option would be to assume that any values that contained spaces (' ') are not encoded (since URLEncoded or application/x-www-form-urlencoded would not contain spaces). Are there edge cases I might miss?