Welcome Guest, Not a member yet? Register   Sign In
Searching by tags with special characters?
#1

[eluser]gRoberts[/eluser]
hi all,

I've implemented a simple tag search for a clients site which works fine unless you type in characters like "'@# etc.

I then urlencoded the tag being used as the parameter but its still not working properly.

How do people handle tags with special characters in?

Cheers

Gavin
#2

[eluser]Randy Casburn[/eluser]
Have you considered using htmlentities or htmlspecialchars instead? They provide a little better treatement of those characters since they are not concerned with how the browser implements URLs.

Randy
#3

[eluser]gRoberts[/eluser]
Unfortunately it doesn't work Sad

Here is a test I used to try each method:

Code:
htmlspecialchars: <a href="http://test.domain.com/tags/search/A dodgy tag¬!&quot;£$%^&amp;*()_+=-&lt;&gt;?/.">A dodgy tag¬!"£$%^&*()_+=-<>?/.</a>
htmlentities: <a href="http://test.domain.com/tags/search/A dodgy tag&not;!&quot;&pound;$%^&amp;*()_+=-&lt;&gt;?/.">A dodgy tag¬!"£$%^&*()_+=-<>?/.</a>
urlencode: <a href="http://test.domain.com/tags/search/A+dodgy+tag�!">?/.">A dodgy tag¬!"£$%^&*()_+=-<>?/.</a>

Urlencode seems the best method but CI won't accept it as a parameter (error 400)

I appreciate your help!

Thanks

Edit: The forum has removed some of the urlencoded chars....
#4

[eluser]Randy Casburn[/eluser]
I misunderstood -- I didn't realize you were translating your tag directly into URIs. I thought you were simply encoding variables.

My bad. Another option then is base64_encode().

Randy
#5

[eluser]gRoberts[/eluser]
That was my last option although defeats the point. I'll see what my client says although I doubt he would settle with base64 encoding Sad

Thank you again!




Theme © iAndrew 2016 - Forum software by © MyBB