Decode user input with special characters
I have a search script where the user input some querywords that are sent with GET. If the user input contains special characters e.g. äpple the url becomes search.php?q=äpple and 开发者_如何学JAVAeverything works fine. But if the user reruns this url search.php?q=äpple the browser address field shows search.php?q=%E4ppleand the query fails. How should I decode that string. urldecodedid not work. I thought this was exactly what it was for so is something else wrong? Or which other functions can I try?
UPDATE
if I use utf8_encode on the search.php?q=%E4pple it produces the right ächar but if the string in the url is sent by GET and thus correctly (and working) äalready, the utf8_encode messes it up.
I guess I can make a condition were I check the encoding before doing something but isnt it an easier way??
Solved it by checking the encoding of $_GET['q'] and handle it appropriately for the result of the encode check. See http://php.net/manual/en/function.utf8-encode.php for functions that check encode.
加载中,请稍侯......
精彩评论