I am developing a website that allows people to create their own translator. They can select the URL name and it is sent to the database and I use .htaccess to redirect website.com/nameoftheirtranslator
in
website.com/translator.php?name=nameoftheirtranslator
Here is my problem:
I recently noticed that someone created a translator with special characters in the name → "LAEFÊVËŠI".
But when it is processed (sent to the php file, then mysqli_real_escape_string ) and added to the database, it looks like just "LAEFVI", so you can see that special characters were lost somewhere.
I'm not quite sure what to do here, but I think there are two ways:
- Try to save characters and make some encodings (I don’t know where to start)
- Omit them and tell users to use only “normal” characters in their translator names (not perfect).
I am wondering if there might be a possible URL, such as website.com/LAEFÊVËŠI , which can be interpreted by the server?
EDIT1: I notice that a stack overflow on this very issue translates the special characters in my header to .../using-special-characters-in-urls ! This seems like a great solution, I think I could make a function that translates special characters like â into their usual equivalent (like â)? And I suppose I would just ignore other characters like /#@"',& ? Now that I think about it, there should be some pretty standard / effective strategies to solve such problems.
EDIT2: Actually, now that I think about it (in more detail) - I really want this thing to be used by people of any language (and not just English), so I would really like to be able to have special characters in URLs. Having said that, I just discovered that Google does not interpret â as a , so it may be difficult for people to find the LAEFÊVËŠI translator if I do not translate the letters into regular characters. Ahh!
source share