I could actualize by customizing this plugin.
I hope that it will be embed to this plugin .. (^^;
[Summary]
For directly opening Microsoft Excel in Japanese, the Shift-JIS encoding must be used.
However, Japanese encoding has very difficult issue because it is not single one.
* For example:
1. Shift-JIS is the standard encoding for Japanese Applications.
2. EUC-JP is for older UNIX system.
3. ISO-2022-JP (JIS) is the standard encoding for Japanese E-mail message.
4. UTF-8 is the current popular encoding for latest devices or systems, such as Gmail, SmartPhone, and so on.
Moreover, Shift-JIS includes special characters for Japanese.
Then, UTF-8 only supports some characters among them because the capacity of UTF-8 is not enough.
By coping with Japanese Microsoft Excel, 2 steps are needed.
1. Fixed Shift-JIS encoding characters to UTF-8 because they may slip into DB.
2. Convert UTF-8 to Shift-JIS supported Windows OS using mb_convert_encoding() function.
* mb_convert_encoding is included mb_string module(http://php.net/manual/en/book.mbstring.php).
[Operation]
1. Copy "ExportToCsvUTF8.php" file to "ExportToCsvShiftJIS.php"
* ExportToCsvShiftJIS.php
(1) Original
class ExportToCsvUTF8 extends ExportBase implements CFDBExport {
(1) Changed
class ExportToCsvShiftJIS extends ExportBase implements CFDBExport {
(2) Original
public function setUseBom($use) {
$this->useBom = $use;
}
(2) Added
public function setUseBom($use) {
$this->useBom = $use;
}
// Convert Shift-JIS (Standard Encoding for Japanese Applications) to UTF-8.
public function japanese_convert_utf8_to_sjis ($str){
$utf_escape_patterns_revert =array(
// The code number of Japanese two-byte character "ー" is separated by Japanese encoding types.
'/\xE2\x80\x93/' => "\xE2\x88\x92",
);
$str =preg_replace(
array_keys($utf_escape_patterns_revert),
array_values($utf_escape_patterns_revert),
$str);
return $str;
}
(3) Original
// Security Check
if (!$this->isAuthorized()) {
$this->assertSecurityErrorMessage();
return;
}
(3) Added
// Security Check
if (!$this->isAuthorized()) {
$this->assertSecurityErrorMessage();
return;
}
// If mb_convert_encoding function is not enabled (mb_string module is not installed), the converting is finished.
if (!function_exists('mb_convert_encoding')){
return;
}
(4) Original
$this->echoHeaders(
array('Content-Type: text/csv; charset=UTF-8',
"Content-Disposition: attachment; filename=\"$formName.csv\""));
(4) Changed
$this->echoHeaders(
array('Content-Type: text/csv; charset=Shift_JIS',
"Content-Disposition: attachment; filename=\"$formName.csv\""));
(5) Original
printf('"%s",', str_replace('"', '""', $cell));
(5) Changed
printf('"%s",', str_replace('"', '""', mb_convert_encoding($this->japanese_convert_utf8_to_sjis($cell),"SJIS-win","utf-8")));
*CF7DBPluginExporter.php
(6) Original
switch ($encoding) {
......
......
......
case 'CSVUTF8':
default:
require_once('ExportToCsvUtf8.php');
$exporter = new ExportToCsvUtf8();
$exporter->setUseBom(false);
$exporter->export($formName, $options);
break;
}
(6) Added
switch ($encoding) {
......
......
......
case 'CSVSJIS':
require_once('ExportToCsvShiftJIS.php');
$exporter = new ExportToCsvShiftJIS();
$exporter->export($formName, $options);
break;
case 'CSVUTF8':
default:
require_once('ExportToCsvUtf8.php');
$exporter = new ExportToCsvUtf8();
$exporter->setUseBom(false);
$exporter->export($formName, $options);
break;
}
* CFDBViewShortCodeBuilder.php
(7) Original
(7) Addded
*CFDBViewWhatsInDB.php
(8) Original
(8) Added
[Other Custom]
For using normal characters in "Filter".
(admin-ajax.php?......&filter=e-mail=example@example.com)
* CFDBFormIterator.php
(1) Original
foreach ($this->dataIterator->displayColumns as $aCol) {
$row[$aCol] = $this->dataIterator->row[$aCol];
(2) Added
foreach ($this->dataIterator->displayColumns as $aCol) {
$row[$aCol] = $this->dataIterator->row[$aCol];
if ($aCol == 'filter'){
$row[$aCol] = urldecode($row[$aCol]);
$row[$aCol] = urlencode($row[$aCol]);
}