Question

I have a problem which i can't seem to find the solution to. I am trying to pull data from the World of Warcraft armory with the provided tools, which works fine:

<?php
$toon = 'http://eu.battle.net/api/wow/character/(realm)/(character name)';
$data = file_get_contents($toon);
$obj = json_decode($data);?>
<img src="http://eu.battle.net/static-render/eu/<?php echo $obj->thumbnail; ?>"> </img><br />
<?php
echo "Name: " . $obj->name . "<br />";
echo "Level: " . $obj->level . "<br />";
echo "Image: " . $obj->thumbnail . "<br />";
?>

The thing im trying to retrieve is the thumnail and for the rest names/level etc dont matter to me. The problem only arrives when the name starts using special characters like:

á,â,etc (http://www.utf8-chartable.de/)

The problem is more or less that the armory api only allows things like

á = %C3%A1
â = %c3%a2

Which is a bit weird since the default page simply converts these back to normal letters. But the Api doesnt support it.

example:
http://eu.battle.net/api/wow/character/darkspear/J%C3%ADmmeh (is api)
http://eu.battle.net/wow/en/character/darkspear/Jímmeh/simple (normal armory page)

My question now is can somebody please help me figure out a way to convert the á to the hex code?

&charname (getting the information from some input field normal characters)
**Converting the &charname with special characters to the charname with hex code's)**
&realmname = http://eu.battle.net/api/wow/character/(realm name)
&toon = &realmname.&charname

(continue the rest of the code)

Was it helpful?

Solution

URLs can only contain a subset of ASCII characters, they do not support characters like "á".
To include such a non-ASCII character in a URL, you need to urlencode it.

If a browser displays the URL as darkspear/Jímmeh/simple, that's simply the browser prettifying the URL for display.

OTHER TIPS

After a good nights sleep and some more work i found out that it doesnt exactely work :(

The problem still lies in the fact that now for example:

á becomes %E1 which works ofcourse as its inteded. But this link is still useless for the wow API. But after some searching i finally found the way if you want to get such a link you will have to do this:

urlencode(utf8_encode($test));

This will make the string utf8 and then change that into a url encode resulting in exactely what i needed :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top