This may be simple, and I may be just being an idiot and doing the wrong search term.
What I want is to take a Uri, and replace certain elements with it's hex counterpart, for a query string.
I use String.Replace() and this is getting tedious.
Example, myQueryString=c# .net html parser becomes myQueryString=c%23+.net+html+parser
I'd like to be able to do the reverse as well.
Any ideas other than a string.Replace for every element that might show up in one of these?
EDIT: I guess I could create an array of characters that don't need converted A-Z, a-z, etc.. then loop through the string and only replace what does need it. This seems stupid though.
Question
scumdogmillionaire
This may be simple, and I may be just being an idiot and doing the wrong search term.
What I want is to take a Uri, and replace certain elements with it's hex counterpart, for a query string.
I use String.Replace() and this is getting tedious.
Example, myQueryString=c# .net html parser becomes myQueryString=c%23+.net+html+parser
I'd like to be able to do the reverse as well.
Any ideas other than a string.Replace for every element that might show up in one of these?
EDIT: I guess I could create an array of characters that don't need converted A-Z, a-z, etc.. then loop through the string and only replace what does need it. This seems stupid though.
Edited by rev23devLink to comment
Share on other sites
5 answers to this question
Recommended Posts