How to convert special characters?

Asked

Viewed 440 times

2

I have a search system, but it doesn’t respond very well with special characters, like: ç, ã, á, ô, etc..

So I want us to input the user type for example: "Union" and GET['nome'] come out kind of like this: Uni%C3%A3o.

I’ve tried using the htmlspecialchars but nothing happens!

The riot is, the search is on the Supercell API developer of Clash of Clans, and the search is only successful when special characters are in this format!

  • 1

    This format is the encoded url RFC 3629. Why exactly do you want it to be in this format to solve the search problem in your database? (*the negative is not mine.. but I voted to close as "not clear enough")

  • Solved, it is because the search is in the Supercell API developer of Clash of Clans, and the search is only successful when special characters are in this format!

  • Okay, I withdrew the vote and added the explanation at the end of your question. Next times make it clear. And on the solution just use urlencode(). You don’t need htmlentities()... But you may still have problems depending on the charset. So don’t rely too much because inconsistencies may occur.

  • Thank you, that’s my only problem in the system

1 answer

4


Use the function urlencode:

$string = "União";
echo htmlentities(urlencode($string)); // Uni%C3%A3o

Browser other questions tagged

You are not signed in. Login or sign up in order to post.