-2

I have 2 similar PHP pages, one displays the UK £ symbol correctly, the other displays a black diamond with a ? in it.

In order to diagnose the problem I cut the code down and they are now identical, but still display differently. How can that be??? This is the code `

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
</head>

<body>
<?php
echo '<p>';

echo "£"."123";

?>
</body>

</html>`

While working with the original code it seemed that I could fix one by removing the charset=utf8 but if I removed it from the other it prefixed the £ with a capital A with an accent.

What is happening here?

Mick Sulley
  • 99
  • 2
  • 11

2 Answers2

1

You have configured another charset in your apache configuration. Maybe your php are proccessed with ISO-8859-1 and you are defining in your HTML UTF-8. That's an inconsistency. Try to define UTF-8 in your apache configuration.

See this post:

How to change the default encoding to UTF-8 for Apache?

In httpd.conf add (or change if it's already there):

AddDefaultCharset utf-8

Community
  • 1
  • 1
Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
1

The reason the issue was occurring was that the PHP files were saved with different encoding. The one which behaved okay had encoding UTF-8, while the problematic file had encoding Windows-1252. I use Bluefish and it all looked okay in there, but when I ran the cat command on the file I could see the odd character.

Thanks for your help!

Sᴀᴍ Onᴇᴌᴀ
  • 8,218
  • 8
  • 36
  • 58
Mick Sulley
  • 99
  • 2
  • 11