0

For this base64 encoded string "Q8Ju/Mbi4UDGBt2aqXhG7Q=="

PHP 5.5 and lower returns this: CÂnüÆâá@ÆÝš©xFí

PHP 5.6 and higher returns this: C�n����@�ݚ�xF�

It appears to be a difference in how the function handles character encoding, but I can't find any documentation on it. I recently upgraded to a server using the latest version of PHP and encountered this error with data being sent to me, that I am not encoding. So using PHP 7, I need to be able to to decrypt the strings I am receiving to get the same result as PHP 5.5 and earlier.

Erinly
  • 3
  • 2
  • $string = "C�n����@�ݚ�xF�"; iconv('ISO-8859-1'', 'UTF-8', $string); – Erinly Nov 13 '19 at 18:22
  • Yes I am trying to upgrade to 7. That is why I was having this problem. – Erinly Dec 06 '19 at 18:14
  • Sorry, I misunderstood. Could you show the output of `echo mb_internal_encoding();`? – Dharman Dec 06 '19 at 18:19
  • 1
    Does this answer your question? [UTF-8 all the way through](https://stackoverflow.com/questions/279170/utf-8-all-the-way-through) – Dharman Dec 06 '19 at 18:59
  • 1
    Since PHP 5.6 the default encoding is UTF-8. You need to make sure that you use it everywhere in your code. – Dharman Dec 06 '19 at 19:00

0 Answers0