2013-10-13 Junichi Satoh <junichi@rworks.jp>

* godmode/alerts/alert_commands.php, include/functions_io.php: Fixed
	that unexpected fields descriptions are set when multi-byte characters
	are entered.
	It is caused by json_encode(). It escapes unicode used by multi-byte
	characters. I've created io_json_mb_encode(), replacement of
	json_encode() for multi-byte characters.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8902 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
jsatoh 2013-10-13 23:13:23 +00:00
parent abd32e8580
commit bf8e5cf187
3 changed files with 27 additions and 4 deletions
pandora_console

View File

@ -1,3 +1,12 @@
2013-10-13 Junichi Satoh <junichi@rworks.jp>
* godmode/alerts/alert_commands.php, include/functions_io.php: Fixed
that unexpected fields descriptions are set when multi-byte characters
are entered.
It is caused by json_encode(). It escapes unicode used by multi-byte
characters. I've created io_json_mb_encode(), replacement of
json_encode() for multi-byte characters.
2013-10-12 Junichi Satoh <junichi@rworks.jp>
* include/help/ja/help_reporting_advanced_tab.php,

View File

@ -149,8 +149,8 @@ if ($create_command) {
$info_fields .= ' Field'.$i.': ' . $fields_values[$i - 1];
}
$values['fields_values'] = json_encode($fields_values);
$values['fields_descriptions'] = json_encode($fields_descriptions);
$values['fields_values'] = io_json_mb_encode($fields_values);
$values['fields_descriptions'] = io_json_mb_encode($fields_descriptions);
$values['description'] = $description;
$name_check = db_get_value ('name', 'talert_commands', 'name', $name);
@ -200,8 +200,8 @@ if ($update_command) {
$info_fields .= ' Field'.$i.': ' . $fields_values[$i - 1];
}
$values['fields_values'] = json_encode($fields_values);
$values['fields_descriptions'] = json_encode($fields_descriptions);
$values['fields_values'] = io_json_mb_encode($fields_values);
$values['fields_descriptions'] = io_json_mb_encode($fields_descriptions);
$values['name'] = $name;
$values['command'] = $command;

View File

@ -415,4 +415,18 @@ function __ ($string /*, variable arguments */) {
return vsprintf ($l10n->translate ($string), $args);
}
/*
* json_encode for multibyte characters.
*
* @param string Text string to be encoded.
*/
function io_json_mb_encode($string){
$v = json_encode($string);
$v = preg_replace_callback("/\\\\u([0-9a-zA-Z]{4})/",
create_function('$matches', 'return mb_convert_encoding(pack("H*", $matches[1]), "UTF-8", "UTF-16");'
), $v);
$v = preg_replace('/\\\\\//', '/', $v);
return $v;
}
?>