vadimyer Posted July 2, 2011 Share Posted July 2, 2011 My project is based on CodeIgniter, but I guess this question isn't about it at all. First, I have enabled query strings and a search function. Search string passes to the “searchterm” variable and when I pass it through the form, it works fine and looks like: http:// local/home/search/?searchterm=testtesttest Okay, now when I input some cyrillic string in a search form, it works fine as well, the URI would be for example: http:// local/home/search/?searchterm=привет (in chrome) or http:// local/home/search/?searchterm=������ (in IE, Opera etc.) Two above cases work fine, BUT WHEN I enter the CYRILLIC search string directly from the address bar (for example, in Opera or IE) it doesn’t wanna search anything. $_GET[‘searchterm’] is empty, and as for QUERY_STRING, it is something like searchterm=������ (all data from profiler). I urldecode my string from the controller, but it somehow doesn’t work. I also tried some iconv() cases, from what I’ve googled, but they also didn’t work. So the question is why all other browsers except chrome doesn’t retrieve CYRILLIC $_GET variable from the address bar if it was entered from there? Passing through the form everything works fine. Thanks in advance, guys. Hope for your help. P.S. I've also found: %D0%BD%D0%BE%D1%87%D0%B0%D0%BB%D0%BE this is passed from the form, accept-charset is set to UTF-8. In that case, as I said, everything works fine. And: %ED%E0%F7%E0%EB%EE this comes in the address bar when typing the string directly inside the address bar. So I guess every browser changes my cyrillic symbols into something strange... I don't know Don't forget that with Chrome everything works fine! Maybe it's because by default this browser doesn't encode cyrillic symbols in wrong way like other browsers. Quote Link to comment https://forums.phpfreaks.com/topic/240949-some-problem-with-encoding-_get-variable-from-address-bar/ Share on other sites More sharing options...
monkeytooth Posted July 3, 2011 Share Posted July 3, 2011 I'm going to go out on a limb, though I'm not going to say with certainty that this is the case. But.. It is 1 of 2 possibilities in my mind (even if I am wrong). But it could be either a browser setting, which that setting doesn't encode properly or handle the data as you would hope. Or.. in a similar notion the way the page is expected to be say you have UTF-8 en-US as the format for the browser.. it could be messing it up there to. I wont say quote me on this, but its worth at the least looking into. Quote Link to comment https://forums.phpfreaks.com/topic/240949-some-problem-with-encoding-_get-variable-from-address-bar/#findComment-1237814 Share on other sites More sharing options...
vadimyer Posted July 3, 2011 Author Share Posted July 3, 2011 Hey, thanks for the answer! Yeah, it seems that's a browser problem. Chrome encodes the URI in some right way, but others encode it as ASCII windows-1251. So for example, if one symbol "n" (in cyrillic) would be %EF%D0% in UTF-8, other browsers encode it as %ED%, see the difference? And that's why I can't urldecode() this further, so I'm stuck. Quote Link to comment https://forums.phpfreaks.com/topic/240949-some-problem-with-encoding-_get-variable-from-address-bar/#findComment-1237829 Share on other sites More sharing options...
monkeytooth Posted July 3, 2011 Share Posted July 3, 2011 if these 4byte commands or what have you will be the same generally speaking, maybe rather than passing it for what its worth you convert it on one end to something both ends can recognize.. keeping the variables the same per say but giving them an extra definition when being sent out so the other site can recognize it. Quote Link to comment https://forums.phpfreaks.com/topic/240949-some-problem-with-encoding-_get-variable-from-address-bar/#findComment-1237838 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.