0

The pound symbol in my php file when is sent by email is converted to strange '」' symbol.

I have tried many different solutions but none seems to work.

Have tried tying replacing '£' with &pound etc...

This is in my header:

<meta http-equiv="content-type" content="text/html; charset=utf-8" />
$message .= "Price Each: £".$row_get['price']. "\n";  
mail($to1, $subject1, $message, $header1); // send the e-mail to customer

Thanks in advance

user2342558
  • 5,567
  • 5
  • 33
  • 54
jackam
  • 53
  • 1
  • 9

2 Answers2

1

The problem is an encoding problem. You're not seeing an UTF-8 rendering.

The £ symbol is encoded as 0xA3, but in the MS932 encoding ("Japanese ANSI"), 0xA3 is the '」' symbol you are seeing.

To properly set the encoding of the email, you will need to add

$headers = 'Content-Type: text/html; charset=utf-8' . "\r\n";

to your headers.

You should also double check that your file is correctly encoded in UTF-8. If you write the pound sign in MS932 encoding, that would be encoded as 65410 65379. Coincidentally, &#65379; is the same '」' symbol (&#65410;&#65379; would display ツ」).

If you want to learn more, this is more thoroughly explained in this SO answer by Jon Skeet (Java, but the root cause is the same).

Mathias-S
  • 787
  • 3
  • 9
0

Do it like this

$header1  = 'MIME-Version: 1.0' . "\r\n";
$header1 .= 'Content-type: text/html; charset=utf-8' . "\r\n";
mail($to1, $subject1, $message, $header1);
ajit.prazanna
  • 134
  • 2
  • 5