Instead of showing -

’ displayed instead - on the php page

I tried using different types of coding, for example:

 <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 the result is the same. What could be the problem?

Enter

<strong style="color:#A8A8A8;">1</strong> - Lorem Ipsum.

Result

1 - Lorem Ipsum.

+6
source share
5 answers

Make sure your html header points to utf8

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 

This usually does the trick for me (obviously, if the contents of IS utf8).

You do not need to convert html objects if you specify 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'); ?> 

Perhaps this will help you.

+4
source

It looks like your source data is being converted from one to another. Try to make sure ALL steps have the same encoding.

  • Is your data (MySQL?) Saved as UTF8?
  • Is your .php file saved as UTF8?

Conversion errors like these usually appear when processing UTF8 data in the form of ISO-8859-1 data. (multibyte or single-byte? not sure).

+2
source

The fact that the meta tag does not change the result is a strong indicator that something redefines it; this is probably the encoding specified in the HTTP header (which takes precedence over the meta tag), are you sure you are not setting it?

+2
source

Your document is most likely encoded in UTF-8, since â€" is a representation of the iso-8859-1 encoded character of UTF-8 .

What you need is a meta tag that you describe:

 <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 

Since it does not work, the tag can be ignored. The suggestion is to use a browser and check which encoding it is trying to use (Tools - Encoding in Chrome).

  • If the browser uses UTF-8, you have double characters. Check your code if you don't have excessive utf8_encode(...)
  • If the browser uses Latin1 (iso-8859-1), your tag is ignored or overridden by the HTTP header. Try validating your HTML with online validation. Check the transferred header information using the browser development tool to make sure that iso-8859-1 is not set as the encoding.
+1
source

With the same problem, when creating a file from javacode and setting the encoding to UTF-16, I did the trick.

0
source

All Articles