最新ページ

mantis - XINUJP - ChangeWebLog

最終更新時間: 2019-08-15 09:35

2010-09-23 Thu

Mantis で日本語 CSV 出力 [mantis]

Mantis の CSVエクスポートは, DB 内のコードをそのまま出力.
なので, UTF-8 で出力されて見事に文字化け.
で, UTF-8 -> SJIS 変換の改造.
ここを参考に.
何とか動いている.

diff -U 3 csv_export.php.orig csv_export.php
--- csv_export.php.orig 2010-09-22 09:41:17.000000000 +0900
+++ csv_export.php 2010-09-23 16:09:47.000000000 +0900
@@ -90,7 +90,7 @@
}
# end of fix

- echo $t_header;
+ echo mb_convert_encoding($t_header,'SJIS', 'UTF-8' );

# export the rows
foreach ( $t_rows as $t_row ) {
@@ -98,7 +98,7 @@
 
  foreach ( $t_columns as $t_column ) {
  if ( !$t_first_column ) {
- echo $t_sep;
+ echo mb_convert_encoding($t_sep,'SJIS', 'UTF-8' );
  } else {
  $t_first_column = false;
  }
@@ -110,12 +110,12 @@
  helper_call_custom_function( $t_column_value_function, array( $t_column, $t_row, COLUMNS_TARGET_CSV_PAGE ) );
  $t_value = ob_get_clean();
 
- echo csv_escape_string($t_value);
+ echo mb_convert_encoding(csv_escape_string($t_value),'SJIS', 'UTF-8' );
  } else {
  $t_function = 'csv_format_' . $t_column;
- echo $t_function( $t_row->$t_column );
+ echo mb_convert_encoding($t_function( $t_row->$t_column ),'SJIS', 'UTF-8' );
  }
  }
 
- echo $t_nl;
+ echo mb_convert_encoding($t_nl,'SJIS', 'UTF-8' );
  }