3

I just noticed something in my testing. I was searching for questions tagged "C#" and the questions come back tagged "C".

Code Poet's SOAPI javascript formats the route thusly:

http://api.stackoverflow.com/1.0/questions?tagged=c%23&sort=activity&order=desc

His works, whereas mine includes the "#" even when I HttpUtility.HtmlEncode it. What am I missing, and is there a quick and dirty converter?

0

2 Answers 2

5

Use UrlEncode not HtmlEncode.

# is legal in HTML, but a restricted character in URLs.

0
0

I will write a test in Soapi.CS to see how it goes. C#<->JS is apples/oranges as the browser is pretty good at taking care of those things.

looks like soapi.cs is not handling it well either.

http://api.stackoverflow.com/1.0/search?intitle=C%2523

apparently I am double urlencoding. or maybe i am encoding when I don't need to and the webrequest is encoding it again. I suspect that is the case.

Not sure why you are simply dropping the hash. I will post findings later tonight.

Thanks, Dave. Misreading your question helped me track down a bug in my code! I was encoding each parameter and then again when I build the query.

2
  • Normally I would agree with you, but if you go to that route in your browser and use the "#" instead of the "%23" you'll get different results. Jul 24, 2010 at 1:11
  • If you try this in StackMobile, you'll see that the '#' is converted to '%23' as per Kevin's answer. The reason I say this is because I made this mistake too originally :) Jul 24, 2010 at 6:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .