Im使用php和slickgrid来显示数据网格结构。。一切都很好。但当我换成日语时,我的网站是多语言的。。我在java脚本方面有这个错误,数据是以json的形式从php发送的
SyntaxError: unterminated string literal
{ id: "Lang_length", name: "最大値以上の長さ << error here
我已经为内容做了utf8_encode
和htmlspecialchars
,但它仍然在破坏
如何使用php正确编码日语字符
slickgrid
从php
侧获取的数据
var columns = [
{ id: "go_to", name: "è¡Œã", field: "go_to", formatter: htmlFormatter, sortable: true, width:100 },
{ id: "product_name", name: "製å“", field: "product_name", formatter: htmlFormatter, sortable: true, width: 400 },
{ id: "product_description", name: "記述", field: "product_description", formatter: htmlFormatter, sortable: true, width: 475 }
更新@pekkaPhp侧上的代码
if(strtolower($this->view->title)=="packaging materials")
{
$pahead_det = '{ id: "go_to", name: "' . PackAssist_Locale::translate('Go to') . '", field: "go_to", formatter: htmlFormatter, sortable: true,width: 75 },
{ id: "product_name", name: "' . PackAssist_Locale::translate('Group/Part') . '", field: "product_name", formatter: htmlFormatter, sortable: true, width: 400 },
{ id: "product_description", name: "' . PackAssist_Locale::translate('Description') . '", field: "product_description", formatter: htmlFormatter, sortable: true, width: 500 },';
}else{
$pahead_det = '{ id: "go_to", name: "' . PackAssist_Locale::translate('Go to') . '", field: "go_to", formatter: htmlFormatter, sortable: true, width: 75 },
{ id: "product_name", name: "' . PackAssist_Locale::translate('Group/Part') . '", field: "product_name", formatter: htmlFormatter, sortable: true, width: 400 },
{ id: "product_description", name: "' . PackAssist_Locale::translate('Description') . '", field: "product_description", formatter: htmlFormatter, sortable: true, width: 500 },';
}
if (strtolower($this->view->title) == "packaging materials") {
$checkin = array();
foreach ($mergearray as $m) {
if (isset($m['part_id'])) {
$getpropertyhead = $propertygrp_model->gridListPropertyHead($m['part_group_id']);
if (count($getpropertyhead) > 0) {
foreach ($getpropertyhead as $property) {
array_push($property_data_list, $property->pg_pd_id);
if (!in_array($property->pd_name_uniquename, $checkin)) { //build the string with check to avoid redundancy
$pahead_det .= '{ id: "' . $property->pd_name_uniquename . '", name: "' . $property->language_data_content . '", field: "' . $property->pd_name_uniquename . '", sortable: true, width: 150,formatter: htmlFormatter },';
}
array_push($checkin, $property->pd_name_uniquename);
}
}
}
}
}
$this->view->pahead_det = substr($pahead_det, 0, -1); //header
谢谢大家。。我得到了答案,我使用了这个功能
public static function characterEscape($str) {
return addcslashes($str, "'''''"&'n'r<>");
}