Jump to content

String conversion


Arkane

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/143199-string-conversion/
Share on other sites

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. :-[

Link to comment
https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751242
Share on other sites

<?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.

Link to comment
https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751449
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/143199-string-conversion/#findComment-751720
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.