Reputation: 175
’
is being displayed instead of -
in php page
I tried using different encoding types like:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
and
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
but result is the same. What could be the problem?
Input
<strong style="color:#A8A8A8;">1</strong>
– Lorem Ipsum.
Result
1 – Lorem Ipsum.
Upvotes: 6
Views: 17019
Reputation: 1808
Had the same problem when creating a file from javacode and setting the encoding to UTF-16 did the trick.
Upvotes: -1
Reputation: 77965
Your document is most likely encoded in UTF-8 since –
is the iso-8859-1 presentation of the UTF-8 encoded character –
.
What you need is the meta-tag you describe:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
Since it isn't working, the tag might to be ignored. Suggestion is to use the browser and check what encoding it tries to use (Tools - Encoding in Chrome).
utf8_encode(...)
Upvotes: 1
Reputation: 126787
The fact that the meta tag doesn't change the output is a strong indicator that there's something overriding it; probably it's the charset specified in the HTTP header (which has precedence over the meta tag), are you sure you're not setting it there?
Upvotes: 2
Reputation: 8084
Make sure your html header specifies utf8
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
That usually does the trick for me (obviously if the content IS utf8).
You don't need to convert to html entities if you set the content-type.
check http://php.net/manual/en/function.mb-convert-encoding.php
<?php
header('Content-Type: text/html; charset=utf-8');
mb_internal_encoding('utf-8');
?>
may be this will help you.
Upvotes: 5
Reputation: 191
It looks like your source data is converted from one to another encoding along the way. Try to make sure ALL steps have the same encoding.
Conversion errors like this usually pop up when handling UTF8 data as ISO-8859-1 data. (multibyte vs singlebyte? not sure).
Upvotes: 2