0

I am forwarding email from server to php file with script. when I get any special chars, I have string in format which is given in screen shot.

I am doing all in PHP.

Thanks in advance.enter image description here

Mujtaba Ahmad
  • 205
  • 2
  • 10

2 Answers2

3

That's UTF-8 encoded as Quoted-Printable.

Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
0

You can use mb_detect_encoding function from php.

Read more about this here

You can also retrieve data from a file to check the encoding. (like your stored emails).

pr1nc3
  • 8,108
  • 3
  • 23
  • 36
  • According to documentation it can detect ASCII using `auto` – pr1nc3 Dec 18 '17 at 08:15
  • ASCII is the output – pr1nc3 Dec 18 '17 at 08:31
  • It doesn't really detect 8 bit ascii vs 7 bit. Either way, this is quoted printable which is the format used for emails. – Ralph Ritoch Dec 18 '17 at 08:32
  • $a = chr(254)."2017 Dec 10\n=E0=B8=AA=E0=B8=A7=E0=B8=B1=E0=B8=AA=E0=10=B8=A3=E0=B8=B1=E0=B8=9A"; echo mb_detect_encoding($a,"auto"); – Ralph Ritoch Dec 18 '17 at 08:33
  • Here is the best reference I can find on the issue. https://stackoverflow.com/questions/20629938/how-to-detect-cp437-using-php – Ralph Ritoch Dec 18 '17 at 08:41
  • The 7 bit works, the 8 bit doesn't. This is relevant if you need to encode emails. If 7bit there's no need to encode, but if it is 8 bit than you need to usually use quoted printable, or base64. – Ralph Ritoch Dec 18 '17 at 08:45