jQuery网格字符集
我目前正在使用jQuery网格来显示用西班牙语编写的数据,数据用重音符号完美地显示出来,但每当我尝试使用重音符号搜索数据时,服务器就会得到一个格式错误的字符串,如∫√ 相反,这封信带有重音 我也确信这是一个jQuery网格问题,因为我能够在同一页面中发送带有重音符号的数据并提交表单 我还在标题中添加了内容类型,如下所示:jQuery网格字符集,jquery,character-encoding,struts2-jquery,jqgrid,Jquery,Character Encoding,Struts2 Jquery,Jqgrid,我目前正在使用jQuery网格来显示用西班牙语编写的数据,数据用重音符号完美地显示出来,但每当我尝试使用重音符号搜索数据时,服务器就会得到一个格式错误的字符串,如∫√ 相反,这封信带有重音 我也确信这是一个jQuery网格问题,因为我能够在同一页面中发送带有重音符号的数据并提交表单 我还在标题中添加了内容类型,如下所示: <%@ page contentType="text/html;charset=UTF-8" %> <sj:head jquerytheme="redmond
<%@ page contentType="text/html;charset=UTF-8" %>
<sj:head jquerytheme="redmond" locale="es" />
这是我与struts2插件一起使用的jQuery网格的代码
<s:url id="remoteurl" action="tabla-historial-director" />
<s:url id="selectperiodourl" action="periodos" />
<sjg:grid
id="grid"
caption="Trabajos Terminales dirigidos"
dataType="json"
href="%{remoteurl}"
pager="true"
navigator="true"
navigatorAdd="false"
navigatorDelete="false"
navigatorEdit="false"
gridModel="gridModel"
rowList="3,10,15,20"
rowNum="10"
hidegrid="false"
gridview="true"
viewrecords="true"
>
<sjg:gridColumn
align="center"
name="numRegistro"
index="numRegistro"
title="No. de registro"
width="120"
sortable="true"
search="true"
searchoptions="{sopt:['eq']}"
/>
<sjg:gridColumn
name="titulo"
index="titulo"
title="Título"
width="840"
search="true"
searchoptions="{sopt:['cn']}"
/>
<sjg:gridColumn
align="center"
name="tipo"
index="tipo"
title="Tipo"
width="60"
search="false"
/>
<sjg:gridColumn
align="center"
name="periodo"
index="periodo"
title="Periodo"
width="80"
search="true"
surl="%{selectcountrysurl}"
searchoptions="{sopt:['eq'], dataUrl : '%{selectperiodourl}'}"
searchtype="select"
/>
<sjg:gridColumn
align="center"
index="objetivo"
name="objetivo"
editable="true"
sortable="true"
hidden="true"
editrules="{ edithidden : true } "
title="Objetivo"
width="20"
/>
<sjg:gridColumn
search="false"
sortable="false"
name="idTT"
key="true"
title="Acción"
width="80"
formatter="formatLink"
/>
</sjg:grid>
请告诉我如何使用搜索按钮和西班牙语口音,非常感谢您的帮助。这里可能有人解决了类似的问题: 他做了以下工作:
header("text/html; charset=iso-8859-1");
以下是答案中的更多线索:
那家伙说:
UTF-8应该能够处理所有口音和外来字符——为什么不在数据源上使用它呢
首先,一切都应该是UTF-8。我用记事本++加载了文件,转换成utf-8,并手动将字符更改为所需的重音。一旦完成,一切都会很顺利
顺便说一句,除非您的服务器被定义为php process.html文件,否则使用ajax加载的文件不会获得iso字符集。如果坚持使用iso字符集,请请求一个php文件而不是html文件,并在头文件而不是文件本身中定义字符集
这对你有帮助吗
您可以尝试html友好代码,并将其替换到搜索中:
另一个人在这里遇到了一些关于西班牙语的问题:
他写了一个逃逸函数,这可能不是你想要的:
(function($) {
if ($) {
var escape_re = /[#;&,\.\+\*~':"!\^\$\[\]\(\)=>|\/\\]/,
escapeCharacters = {
‘#’: 1,
‘;’: 1,
‘&’: 1,
‘,’: 1,
‘.’: 1,
‘+’: 1,
‘*’: 1,
‘~’: 1,
‘\”: 1,
‘:’: 1,
‘”‘: 1,
‘!’: 1,
‘^’: 1,
‘$’: 1,
‘[': 1,
']‘: 1,
‘(‘: 1,
‘)’: 1,
‘=’: 1,
‘>’: 1,
‘|’: 1,
‘/’: 1,
‘\\’: 1
};
$.escape = function(s){
var ret = ”, offset;
if (s && ((offset = s.search(escape_re)) !== -1)) { // look for an occurence of a special character
ret = s.substr(0, offset) + ‘\\’ + s[offset];
for(var i=offset + 1, len=s.length, ch; i < len; i++){ // assume that another special character may occur so we just loop through the rest of the string
ch = s[i];
ret += (escapeCharacters[ch]? '\\': '') + ch;
}
}
return ret;
};
}
})(window.jQuery);
hth可能有人在这里解决了类似的问题: 他做了以下工作:
header("text/html; charset=iso-8859-1");
以下是答案中的更多线索:
那家伙说:
UTF-8应该能够处理所有口音和外来字符——为什么不在数据源上使用它呢
首先,一切都应该是UTF-8。我用记事本++加载了文件,转换成utf-8,并手动将字符更改为所需的重音。一旦完成,一切都会很顺利
顺便说一句,除非您的服务器被定义为php process.html文件,否则使用ajax加载的文件不会获得iso字符集。如果坚持使用iso字符集,请请求一个php文件而不是html文件,并在头文件而不是文件本身中定义字符集
这对你有帮助吗
您可以尝试html友好代码,并将其替换到搜索中:
另一个人在这里遇到了一些关于西班牙语的问题:
他写了一个逃逸函数,这可能不是你想要的:
(function($) {
if ($) {
var escape_re = /[#;&,\.\+\*~':"!\^\$\[\]\(\)=>|\/\\]/,
escapeCharacters = {
‘#’: 1,
‘;’: 1,
‘&’: 1,
‘,’: 1,
‘.’: 1,
‘+’: 1,
‘*’: 1,
‘~’: 1,
‘\”: 1,
‘:’: 1,
‘”‘: 1,
‘!’: 1,
‘^’: 1,
‘$’: 1,
‘[': 1,
']‘: 1,
‘(‘: 1,
‘)’: 1,
‘=’: 1,
‘>’: 1,
‘|’: 1,
‘/’: 1,
‘\\’: 1
};
$.escape = function(s){
var ret = ”, offset;
if (s && ((offset = s.search(escape_re)) !== -1)) { // look for an occurence of a special character
ret = s.substr(0, offset) + ‘\\’ + s[offset];
for(var i=offset + 1, len=s.length, ch; i < len; i++){ // assume that another special character may occur so we just loop through the rest of the string
ch = s[i];
ret += (escapeCharacters[ch]? '\\': '') + ch;
}
}
return ret;
};
}
})(window.jQuery);
hth这是一个常见的问题,有时也是一个很难解决的问题。。。如果你接受的答案在你之前的问题上接近正确,那么你会发现更多的人愿意帮助你。这是一个常见的问题,有时也是一个很难解决的问题。。。如果你所接受的答案在你之前的问题上几乎是正确的,那么你会发现更多的人愿意帮助你。。