1

我使用 php 和 slickgrid 来显示数据网格结构..一切正常。但是当我更改为日语时,我的网站是多语言的..我在 java 脚本端有这个错误,数据是从 php 作为 json 发送的

SyntaxError: unterminated string literal
{ id: "Lang_length", name: "最大値以上の長さ << error here

我已经完成utf8_encodehtmlspecialchars内容。但它仍然在破坏

如何用php正确编码日文字符

我从php侧面获取的数据slickgrid

 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 }

在 PHP 端更新 @pekka 代码

 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
4

1 回答 1

1

谢谢大家..我得到了答案我使用了这个功能

 public static function characterEscape($str) {
        return addcslashes($str, "\\\'\"&\n\r<>");
    }
于 2013-07-18T10:51:29.827 回答