Special characters in query

Post Reply
abhishek.thakur
Posts: 5
Joined: Thu Aug 26, 2010 11:29 am

Special characters in query

Post by abhishek.thakur »

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
User avatar
mark
Site Admin
Posts: 5513
Joined: Tue Apr 25, 2000 6:56 pm

Special characters in query

Post by mark »

Escape with backslash:
test \# pound
User avatar
jason112
Site Admin
Posts: 347
Joined: Tue Oct 26, 2004 5:35 pm

Special characters in query

Post by jason112 »

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.
User avatar
jason112
Site Admin
Posts: 347
Joined: Tue Oct 26, 2004 5:35 pm

Special characters in query

Post by jason112 »

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>
Post Reply