I have export to csv function which is in export.php. The function is working fine. It is just the display of Japanese character is showing like this: 予約済み Both when i echo the variable in the page and in csv file.
charset is already in UTF-8. It is displaying fine in other pages. I don't know what to do next.
Here's my code:
public function excel()
{
$student_id = $_GET['student_id'];
$lesson = &Chico::getInstance('Controller_Frontend_Lesson');
$defaults = &Chico::getInstance('Model_Defaults');
$get_lesson_history = $lesson->lesson_history(get_user_meta($student_id, 'gge_access_token', true));
$convert_lesson_time = $lesson->convert_lesson_time($get_lesson_history);
$lesson_history = $lesson->sort_history($convert_lesson_time);
$count = 1; $lesson_count = $this->get_lesson_count($lesson_history);
header('Content-Type: text/csv;charset=utf-8');
header(sprintf('Content-Disposition: attachment;Filename=%s.csv', get_user_meta($student_id, 'gge_name', true)));
$outstr = sprintf('PERIOD, %s ~ %s %s', !empty($_GET['begin']) ? $_GET['begin'] : 'Beginning', !empty($_GET['end']) ? $_GET['end'] : 'Present', "\n");
$outstr .= sprintf('STUDENT NAME, %s %s', get_user_meta($student_id, 'gge_name', true), "\n");
$outstr .= sprintf('SKYPE ID, %s %s', get_user_meta($student_id, 'gge_skype', true), "\n");
$outstr .= sprintf('NUMBER OF BOOKINGS, %s %s', $lesson_count, "\n");
$outstr .= sprintf('NUMBER OF LESSONS, %s %s', $lesson_count, "\n\n");
$outstr .= '#, DATE/TIME, TEACHER, STATUS, LESSON, REQUEST, COMMENT';
$outstr .= sprintf('%s', "\n");
if(!empty($lesson_history) && is_array($lesson_history)):
foreach ($lesson_history as $key => $value) {
$lastkey = count($value)-1;
$launched = strtotime($value[$lastkey]['launched']);
$datetime = sprintf('%s %2$s:00 ~ %2$s:50', date(__(get_option( 'date_format' )), $launched), date(__('H'), $launched));
if(strtotime($_GET['begin']) <= $launched && strtotime(sprintf('%s+1 days', $_GET['end'])) >= $launched):
$outstr.= join(',', array($count, $datetime,
$value[$lastkey]['teacher_name'],
$defaults::$status_ja[$value[$lastkey]['status']],
$value[$lastkey]['request_title'],
$value[$lastkey]['request_body'],
$value[$lastkey]['scores']['message']));
$outstr .= sprintf('%s', "\n");
$count++;
endif;
}
else:
$outstr.= join(',', 'No lesson history');
endif;
echo $outstr;
}
Here's the data in csv: STATUS LESSON SAMMY 予約済み KREAN 予約済み