Php outputs instead of -

for example, when I retrieve a program of words from a database instead of a program, what will be shown is program s. 'and - changes to. how can i fix this?

+2


source to share


6 answers


You are treating cp-1252 as iso-8859-1. A very common mistake. Use utf-8 which is standardized or validates input to ensure the user is giving you a valid iso-8859-1 when they say so. In cases where you don't (for example, you get cp-1252), you can transliterate the input to iso-8859-1.



0


source


The replacement character (U + FFFD) means your data is incorrectly encoded. You are probably declaring your output as UTF-8, but your database data is not UTF-8 encoded. Therefore, you need to convert the data to UTF-8. You can use mb_convert_encoding

to do this.



+8


source


Is your data being saved as UTF-8? Try these queries before getting the data:

SET NAMES utf8
SET CHARACTER SET utf8

      

Also make sure you are setting the page encoding:

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />

      

+5


source


This is a character encoding problem: somewhere along the string the character encoding is being interpreted incorrectly. These are the areas you should check, working mostly backwards when you display this page:

When you render the page, you must include the header of the relevant content, either from the server (preferably) or in HTML:

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

      

When you connect to the database, you should issue a query SET NAMES

that tells the database which encoding to use when sending data to your script (note that this has nothing to do with the encoding of your tables).

SET NAMES utf8;

      

Your tables themselves should be defined as the "correct" character encoding:

CREATE TABLE foo (...) CHARSET=utf8;

      

If you have already created a table using latin1

and want to convert them, you will not only release ALTER TABLE

to change CHARSET

, but also to change CHARSET

for each text column ( TEXT

, CHAR

, VARCHAR

).

If all of this seems to be correct, the problem can happen "along the way." That is, if you have another form that sends the data to the database, you also need to update this form ( Content-Type

and SET NAMES

).

+4


source


This sounds like a character set problem, your database and webpage must use the same encoding (or you need to convert between them). Check out this article from Joel on Software. That apostrophe was seemingly a curly apostrophe, and my suspicion of a dash is a dash or similar.

0


source


Can be caused by the use of different characters, like houses Marks and Mark, usually I get this character from MS word and other word processors, annoying

Edit: Blow, I see that stack overflow automatically fixes the character ... my point is, word processors create different characters when you hit the apostrophe button

0


source







All Articles