PHP wrong character set -


I am trying to draw data from a table and output it as a text (RTF) file. The problem is that there are few letters in the content that are similar. For example, if I have Spanish content, then some letters are not recognizable and can not be changed. For example, if I:

'applyación'

changes for the term:

'implementación '

By using a break point, I can see that the string coming from the database is correct, it only happens when the tilde changes. Below is my code:

  header ("content-type: application / RTF; charset = UTF-8;"); Header ("cache-control: public"); Header ("content-description: file transfer"); Header ("Content-Dispute: Attachment; File Name =". $ FileName. ".rtf"); Header ("content-transfer-encoding: binary"); Counterpart $ content;   

Match the output letter set with the character set of the table or replace the character set with the character set in which you want to output.

Assuming that the table uses US-ASCII to store data, and we want it to output it as UTF-8.

  $ content = iconv ('US-ASCII', 'UTF-8 // IGNORE // TRANSLIT', $ content); Counterpart $ content;  

It will transliterate some letters from: from € to Euro, and ignore characters that are not known on the output letter set.

If you resist the US-ASCII as a general encoding CP850 in the Latin-table (alias: Code Page 850, MSDOS Latin-1)

You can alternatively insert your encoding from within. Select your query

  on the table for instance with mysql (converted (using content latin1) as binary) converted using UTF8) as the content < / Code> 

This is useful if the data sent to the database was using a different character set from the table. For example, to send ASCII or ISO-8859-1 data to a table / column using UTF-8 matching

try to find the table character encoding.

  creating show table 'tablain`;  

or

For the table encoding:

  select information_schema.`TABLES` T CCSA.character_set_name, information_schema.`COLLATION_CHARACTER_SET_APPLICABILITY `CCSA WHERE CCSA.collation_name = T.table_collation and T.table_schema =" schemaname "and T.table_name =" tablename ";  

For column encoding:

  information_schema.`COLUMNS` Select from character_set_name where TABLE_SCHEMA = "schemaname" and TABLE_NAME = "tablename" and column = " column name";  

Alternatively, you can try to change the charset header in PHP to match the output of the database table.

  header ("content-type: application / rtf; charset = ISO-8859-1,");  

Comments