abhishek.thakur
Posts: 5 Joined: Thu Aug 26, 2010 11:29 am
Post
by abhishek.thakur » Thu Nov 11, 2010 1:13 pm
Hi,
Could please tell me how to handle the query which has special character "#". For example my query is 'test # pound' so it gives results only for 'test' and truncates rest of the query.
Please help me resolve this issue
Thanks,
Abhishek
mark
Site Admin
Posts: 5513 Joined: Tue Apr 25, 2000 6:56 pm
Post
by mark » Thu Nov 11, 2010 1:58 pm
Escape with backslash:
test \# pound
jason112
Site Admin
Posts: 347 Joined: Tue Oct 26, 2004 5:35 pm
Post
by jason112 » Thu Nov 11, 2010 2:10 pm
If you're constructing the URL for the query yourself, you'll want to replace the # with the code %23 to make it URL-safe.
jason112
Site Admin
Posts: 347 Joined: Tue Oct 26, 2004 5:35 pm
Post
by jason112 » Thu Nov 11, 2010 3:01 pm
or more globally, if you're printing a url like
<a href="search?query=$query">search</a>
You'll want to use the %U fmt code to escape anything that wouldn't be URL-safe.
<fmt '<a href="search?query=%U">search</a>' $query>