我试图删除单引号,但我不知道该怎么做。 我在这里留下相关代码。
response.write "Original: " & rs2("comentario")
comentario = Replace(rs2("comentario"), "ñ", "ñ")
comentario = Replace(comentario, "ó", "ó")
comentario = Replace(comentario, "fÆ", "ó")
comentario = Replace(comentario, "³", "ó")
comentario = Replace(comentario, "Ã", "")
comentario = Replace(comentario, "Â", "")
comentario = Replace(comentario, Chr(39), "")
comentario = Replace(comentario, "'", "")
comentario = Replace(comentario, "\'", "")
response.write "<br>Modificado: " & comentario & "<br>-----------------------<br>"
上面代码的结果就是这个
Original: reunión INNOVAE IÃ'igo Iñake Modificado: reunión INNOVAE I'igo Iñake -----------------------
答案 0 :(得分:1)
我不清楚你正在尝试做什么,或者你遇到了什么问题。如果你想从字符串中删除所有撇号(U + 0027),那么你正在做什么
comentario = Replace(comentario, "'", "")
应该工作得很好。 (使用chr(39)
代替"'"
也是等效的。
但是,您尝试替换的角色可能实际上并不是撇号,而是一些其他类似的角色。也许你输出的字符集不支持字符串中的实际字符,并且它被替换为输出中最接近的最佳匹配(即U + 0027)撇号,你最终看到了。但这些只是猜测,如果不了解更多关于你的设置以及你真正想要做的事情,很难确定。
从更大的角度来看,您似乎试图以某种方式修复先前使用错误字符编码传输的数据。除非您过去尝试修复以这种方式不可逆转地破坏的数据,否则您可能最好更正此问题,并确保在工作流程的所有点使用正确的编码传输数据。请确保Response.CharSet
和Response.CodePage
的设置方式符合您尝试使用的任何文字编码,以及您正确处理表单输入的方式。由浏览器设置的编码。
答案 1 :(得分:1)
我解决了这个改变页面编码部分的问题
<%
CharSet = "ISO-8859-1"
Response.CodePage = 28591
%>
要
<%
Response.CodePage = 65001
Response.CharSet = "utf-8"
%>
并在Notepad ++上将其保存为UTF-8
答案 2 :(得分:1)
这是我为修复有趣角色而创建的内容:
我使用FN_CLEAN去&#34;清洁&#34; STUFF FOR DATABASE INSERT / UPDATE:
function fn_clean(FixWhat)
if (isempty(FixWhat) or isnull(FixWhat) or FixWhat="") then
FixWhat=""
else
apos=chr(39)
quot=chr(34)
FixWhat=trim(FixWhat)
FixWhat=replace(FixWhat," "," ",1,-1,1)
FixWhat=replace(FixWhat,"''",apos & apos,1,-1,1)
FixWhat=replace(FixWhat,"'''",apos,1,-1,1)
FixWhat=replace(FixWhat,VBNullChar,"",1,-1,1)
FixWhat=replace(FixWhat,VBNullString,"",1,-1,1)
FixWhat=replace(FixWhat,VBTab," ",1,-1,1)
FixWhat=replace(FixWhat,VBVerticalTab," ",1,-1,1)
FixWhat=replace(FixWhat,"<ahref=","<a href=",1,-1,1)
FixWhat=replace(FixWhat,"<ahref =","<a href=",1,-1,1)
FixWhat=replace(FixWhat,"<imgsrc","<img src",1,-1,1)
FixWhat=replace(FixWhat,"<spanclass=","<span class=",1,-1,1)
FixWhat=replace(FixWhat,"<spanclass =","<span class=",1,-1,1)
FixWhat=replace(FixWhat,"//<![CDATA[","",1,-1,1)
FixWhat=replace(FixWhat,"//]]","",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"amp;","&",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"<","<",1,-1,1)
FixWhat=replace(FixWhat,">",">",1,-1,1)
FixWhat=replace(FixWhat,"/","/",1,-1,1)
'FixWhat=replace(FixWhat,"../../../images/","/images/",1,-1,1)
FixWhat=replace(FixWhat,"’",apos,1,-1,1)
FixWhat=replace(FixWhat,"’",apos,1,-1,1)
FixWhat=replace(FixWhat,"`",apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(145),apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(146),apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(180),apos,1,-1,1)
'FixWhat=replace(FixWhat,chr(184),apos,1,-1,1)
FixWhat=replace(FixWhat,"_new","_BLANK",1,-1,1)
FixWhat=replace(FixWhat,"_NEW","_BLANK",1,-1,1)
'FixWhat=replace(FixWhat,"ñ","ñ",1,-1,1)
'quotes
'FixWhat=replace(FixWhat,chr(132),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(147),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(148),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(152),quot,1,-1,1)
'FixWhat=replace(FixWhat,chr(168),quot,1,-1,1)
'hyphens
'FixWhat=replace(FixWhat,chr(150),"-",1,-1,1)
'FixWhat=replace(FixWhat,chr(151),"--",1,-1,1)
'dot dot dot
'FixWhat=replace(FixWhat,chr(133),"...",1,-1,1)
'line feed
'FixWhat=replace(FixWhat,chr(10),"[chr-10 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(12),"[chr-12 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(13),"[chr-13 was here]",1,-1,1)
'CR
'FixWhat=replace(FixWhat,chr(21),"<br>",1,-1,1)
'now for everything higher than char 128
'for i = 129 to 255
' c = "&#" & i & ";"
' FixWhat = replace(FixWhat,Chr(i),"'",1,-1,1)
'next
'FixWhat=replace(FixWhat,quot,quot & quot)
'FixWhat=replace(FixWhat,"<br>" & vbCrLf & "<br>" & vbCrLf & "<br>" & vbCrLf,"<br>" & vbCrLf & "<br>" & vbCrLf,1,-1,1)
FixWhat=replace(FixWhat,vbCrLf & vbCrLf,vbCrLf,1,-1,1)
'FixWhat=replace(FixWhat,"<br><br><br><br>","<br><br>",1,-1,1)
'FixWhat=replace(FixWhat,"<br><br><br>","<br><br>",1,-1,1)
'FixWhat=replace(FixWhat,"<table><br>","<table>",1,-1,1)
'FixWhat=replace(FixWhat,"</td><br>","</td>",1,-1,1)
'FixWhat=replace(FixWhat,"<tr><br>","<tr>",1,-1,1)
'FixWhat=replace(FixWhat,"<br><tr>","<tr>",1,-1,1)
'FixWhat=replace(FixWhat,"</tr><br>","</tr>",1,-1,1)
'FixWhat=replace(FixWhat,"<br></tr>","</tr>",1,-1,1)
'FixWhat=replace(FixWhat,"<br><embed","<embed",1,-1,1)
'FixWhat=replace(FixWhat,"background=" & quot & " ","background=" & quot & quot & " ",1,-1,1)
FixWhat=replace(FixWhat,"alt =","title=",1,-1,1)
FixWhat=replace(FixWhat,"alt=","title=",1,-1,1)
FixWhat=replace(FixWhat,"alt= ","alt= ",1,-1,1)
FixWhat=replace(FixWhat,"alt= ","title=",1,-1,1)
FixWhat=replace(FixWhat,"title=" & chr(34) & chr(34),"title=image",1,-1,1)
FixWhat=replace(FixWhat,"title=" & chr(34) & chr(32),"title=image ",1,-1,1)
FixWhat=replace(FixWhat,"align=" & quot & " ","align=left ",1,-1,1)
FixWhat=replace(FixWhat,"border=" & quot & " "," ",1,-1,1)
FixWhat=replace(FixWhat,"this=" & quot & " "," ",1,-1,1)
FixWhat=replace(FixWhat,"width=" & quot & " ","width=10 ",1,-1,1)
FixWhat=replace(FixWhat,"x=" & quot & " "," ",1,-1,1)
FixWhat=replace(FixWhat,"[quote]",""",1,-1,1)
FixWhat=replace(FixWhat,quot,""",1,-1,1)
FixWhat=replace(FixWhat,"'","'",1,-1,1)
end if
fn_clean=FixWhat
End Function
这是我使用的屏幕/输入框中的肮脏,等等:
Function fn_dirty(FixWhat)
if (isnull(FixWhat) or FixWhat="") then
FixWhat=""
else
FixWhat=trim(FixWhat)
FixWhat=replace(FixWhat,"<ahref","<a href",1,-1,1)
FixWhat=replace(FixWhat,"<spanclass","<span class",1,-1,1)
'FixWhat=replace(FixWhat,"ñ","ñ",1,-1,1)
FixWhat=replace(FixWhat," "," ",1,-1,1)
FixWhat=replace(FixWhat,"’","'",1,-1,1)
FixWhat=replace(FixWhat,"'","'",1,-1,1)
FixWhat=replace(FixWhat,"%27","'",1,-1,1)
FixWhat=replace(FixWhat,"'","'",1,-1,1)
FixWhat=replace(FixWhat,"’","'",1,-1,1)
FixWhat=replace(FixWhat,"/","/",1,-1,1)
FixWhat=replace(FixWhat,"''''","'''",1,-1,1)
FixWhat=replace(FixWhat,""",chr(34),1,-1,1)
FixWhat=replace(FixWhat,"%22",chr(34),1,-1,1)
FixWhat=replace(FixWhat,chr(13) & chr(10),"",1,-1,1)
'FixWhat=replace(FixWhat," " & " ","",1,-1,1)
'FixWhat=replace(FixWhat,vbCrLf & vbCrLf,vbCrLf,1,-1,1)
'FixWhat=replace(FixWhat,chr(34)&chr(34)&chr(34),chr(34),1,-1,1)
'FixWhat=replace(FixWhat,chr(10),"[chr10 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(12),"[chr12 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(13),"[chr13 was here]",1,-1,1)
'FixWhat=replace(FixWhat,chr(34) & chr(34),chr(34),1,-1,1)
'FixWhat=replace(FixWhat,"alt='" & chr(32) & "'","alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt=" & chr(34) & chr(32) & chr(34),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt='" & chr(32),"alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt='" & chr(32),"alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"alt=" & chr(34) & chr(32),"alt=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
FixWhat=replace(FixWhat,"title=","alt=",1,-1,1)
'FixWhat=replace(FixWhat,"title='" & chr(32) & "'","title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title=" & chr(34) & chr(32) & chr(34),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title='" & chr(32),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title='" & chr(32),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
'FixWhat=replace(FixWhat,"title=" & chr(34) & chr(32),"title=Put-image-title-here-instead-of-OceanMedia.net" & chr(32),1,-1,1)
FixWhat=replace(FixWhat,"src=" & chr(34) & chr(32),"",1,-1,1)
FixWhat=replace(FixWhat,"src=" & chr(34) & "/images","src=" & chr(34) & "images",1,-1,1)
FixWhat=replace(FixWhat,"background=" & chr(34) & chr(32),"background=" & chr(34) & chr(34) & chr(32),1,-1,1)
FixWhat=replace(FixWhat,"x=" & chr(34) & chr(32)," ",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"amp;","&",1,-1,1)
FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"&&","&",1,-1,1)
FixWhat=replace(FixWhat,"<","<",1,-1,1)
FixWhat=replace(FixWhat,">",">",1,-1,1)
'FixWhat=replace(FixWhat,"&","&",1,-1,1)
FixWhat=replace(FixWhat,"//<![CDATA[","",1,-1,1)
FixWhat=replace(FixWhat,"//]]","",1,-1,1)
FixWhat=replace(FixWhat,"<TABLE","<table",1,-1,1)
FixWhat=replace(FixWhat,"<TBODY>","<tbody>",1,-1,1)
FixWhat=replace(FixWhat,"<TR","<tr",1,-1,1)
FixWhat=replace(FixWhat,"<TD","<td",1,-1,1)
FixWhat=replace(FixWhat,"</TR>","</tr>",1,-1,1)
FixWhat=replace(FixWhat,"</TD>","</td>",1,-1,1)
FixWhat=replace(FixWhat,"<html><br>","<html>",1,-1,1)
FixWhat=replace(FixWhat,"<head><br>","<head>",1,-1,1)
FixWhat=replace(FixWhat,"<body><br>","<body>",1,-1,1)
FixWhat=replace(FixWhat,"<br><tbody>","<tbody>",1,-1,1)
FixWhat=replace(FixWhat,"<tbody><br>","<tbody>",1,-1,1)
FixWhat=replace(FixWhat,"<br><tr>","<tr>",1,-1,1)
FixWhat=replace(FixWhat,"<tr><br>","<tr>",1,-1,1)
FixWhat=replace(FixWhat,"<br><td","<td",1,-1,1)
FixWhat=replace(FixWhat,"<br></html>","</html>",1,-1,1)
'FixWhat=replace(FixWhat,"#34;#34;#34;","""",1,-1,1)
'FixWhat=replace(FixWhat,"#39;#39;#39;","''",1,-1,1)
'FixWhat=replace(FixWhat,""""","""",1,-1,1)
'FixWhat=replace(FixWhat,"'''","''",1,-1,1)
end if
fn_dirty=FixWhat
End Function