Arkane Posted January 30, 2009 Share Posted January 30, 2009 Hey guys, I'm sorry to come to ask something so vague, but unfortunately I'm being driven insane, and hopefully someone here will actually understand me. If not... well, no harm trying, I hope. I am trying to make a script to get an image through another sites API. The problem is, that the ID used to query the site often contains spaces and TM characters and things, and I'm struggling to convert them successfully. For example, to query "Mirror's Edge™" I can search for it properly in FireFox, but for PHP I need to use the query of "Mirror%27s+Edge%99". However, I can't find how to get this. I've tried a variety of utf8_encodes (recommended by the API holders) htmlspecialchars, and urlencodes, but the closest I've gotten is "Mirror%27s+Edge%C2%99" by using a nested urlencode within a utf8_encode, and I can't figure where the %C2 is coming from. I'm sorry for vagueness, but since the API holders dont know (!!!) I thought maybe someone here might by chance have encountered similar. Thanks for any help guys, Arkane Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/ Share on other sites More sharing options...
genericnumber1 Posted January 31, 2009 Share Posted January 31, 2009 Have you tried urlencode() ? edit: sorry, you said you had. Then I have no idea what to do if it doesn't work for you. Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751033 Share on other sites More sharing options...
.josh Posted January 31, 2009 Share Posted January 31, 2009 urlencode seems to work just fine for me.... $string = "Mirror's Edge™"; echo urlencode($string); output: Mirror%27s+Edge%99 Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751034 Share on other sites More sharing options...
Arkane Posted January 31, 2009 Author Share Posted January 31, 2009 urlencode seems to work just fine for me.... You're absolutely right. Thats what I get too. I've managed to confuse myself somewehere because I spent so much time trying to fix it myself and failing. The string I actually need to convert it to is "Mirror%27s+Edge%E2%84%A2", and I've been nowhere near it... just stupid. Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751242 Share on other sites More sharing options...
.josh Posted January 31, 2009 Share Posted January 31, 2009 What is that supposed to translate to? Maybe the problem is that you aren't using the right content charset type? Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751271 Share on other sites More sharing options...
genericnumber1 Posted January 31, 2009 Share Posted January 31, 2009 <?php echo urlencode('Mirror\'s Edge™'); Translates to "Mirror%27s+Edge%E2%84%A2" for me.... php 5.2.5 Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751373 Share on other sites More sharing options...
Arkane Posted January 31, 2009 Author Share Posted January 31, 2009 <?php echo urlencode('Mirror\'s Edge™'); Translates to "Mirror%27s+Edge%E2%84%A2" for me.... php 5.2.5 Hmm, It think Crayon Violent must be right about charset, but I don't really know anything about it. I tried duplicating the line, but definitly doesn't translate to that for me, using 2.5.6 on a Windows host. Although I'm putting money that might have explained it for everyone. Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751449 Share on other sites More sharing options...
genericnumber1 Posted January 31, 2009 Share Posted January 31, 2009 Yeah, I'm on a unix host.. I'd be interested in finding out if the translation is platform specific, though I don't feel dedicated enough to boot into windows to find out. Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751520 Share on other sites More sharing options...
Arkane Posted February 1, 2009 Author Share Posted February 1, 2009 Yeah, I'm on a unix host.. I'd be interested in finding out if the translation is platform specific, though I don't feel dedicated enough to boot into windows to find out. I'll try test on another server if I can... see if I can figure anything out. Would be interested to know at least. Quote Link to comment https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751720 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.