1

I am trying to export data from mysql database to a CSV file, but Thai content is being displayed as ????s. Also, in database it's not taking whatever I enter. If I enter ปดิวรัดา , it's saving as ปดิวรัดา

Please help me.

EDIT: Now, i edited encoding of table and fields to utf8_general_ci and its storing data as i entered into database but still export problem exists.

Original code we have written is here

Jhansi
  • 19
  • 2
  • 6

2 Answers2

0

Set your database encoding to utf8_general_ci

Also check that your column with strings has encoding utf8_general_ci.

sybear
  • 7,837
  • 1
  • 22
  • 38
  • Hello, I just changed both database encoding and column encoding to `utf8_general_ci` and now its storing data as i entered, but when i try to export, its still showing me ????s... what encoding format i should set in `header('Content-Type: text/csv;');` ? – Jhansi Feb 20 '13 at 13:15
  • Yep, you can set the header. Encode your csv file into utf-8. There must be some option to do that. – sybear Feb 20 '13 at 13:30
  • I am already setting it to utf-8, but when i do that its returning ?????s instead of characters. – Jhansi Feb 20 '13 at 13:31
  • Let the file be empty, then convert to utf-8, then use the script. – sybear Feb 20 '13 at 13:36
0

Add this to the beginning if the $buffer you're exporting:

$buffer = chr(239) . chr(187) . chr(191) . $buffer; 

The encoding is UTF with BOM, adding this will add the BOM.

Sharon Haim Pour
  • 6,595
  • 12
  • 42
  • 64