How can I convert these strings in PHP?

1

I have the following instructions ....

echo $parcelamento . "<br>"; 
echo utf8_encode($parcelamento) . "<br>";
echo utf8_decode($parcelamento) . "<br>";

... which respectively return this:

ou 12x de R$ 21,58 sem juros no cartÃÂão
ou 12x de R$ 21,58 sem juros no cartÃÂÃÂÃÂão
ou 12x de R$ 21,58 sem juros no cartão

Can someone tell me how I'm going to return the term card ?

Another solution would be to replace card with card within the proposed sentence but I do not know how to develop none of the solutions.

I'm running a PHP for that XML

    
asked by anonymous 16.03.2015 / 16:25

1 answer

1

The function utf8_encode() should be called iso88591_to_utf8() so as not to confuse both.

In your case, you do not need to use this function because your data is already in UTF-8. It's good to leave your data in UTF-8, as you already do, until the last possible moment.

To make sure you do not "pollute" your XML environment and avoid accidental conversions, declare your HTML as UTF-8 too, as suggested by @qmechanik:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Your XML is already explicitly identified as UTF-8:

<?xml version="1.0" encoding="UTF-8"?>
    
07.04.2015 / 04:03