ASP代码实现自动清除替换ACCESS(MDB)数据库的日文字符的
程序员文章站
2022-08-05 23:45:59
此时我们通常能想到的想法是找一个exe程序,把这个问题解决掉。我原来用c#写过这样一个类似的程序。 google里面应该能找到我以前写的那个。就不说了。 后来某一天,我发现...
此时我们通常能想到的想法是找一个exe程序,把这个问题解决掉。我原来用c#写过这样一个类似的程序。
google里面应该能找到我以前写的那个。就不说了。
后来某一天,我发现asp就能实现。我当时真的觉得自己太屎了。
不过asp的这种方法很不好。容易造成系统崩溃(如果数据库大)。
所以只是写在这里。算是抛砖引玉。
'下面我解释一下下:
function transferjapandc9cnindb()
on error resume next
err.clear
dim objrs,i
set objrs=server.createobject("adodb.recordset")
objrs.cursortype = adopenkeyset
objrs.locktype = adlockreadonly
objrs.activeconnection=objconn
objrs.source="select * from [blog_comment]"
objrs.open()
if (not objrs.bof) and (not objrs.eof) then
for i=1 to objrs.recordcount
'遍历,看看有没有日文,如果有,就溢出了,随便搜索一个东西就行了。搜什么无所谓。因为是遍历access只要指针移动到日文就溢出。
objconn.execute("select * from [blog_comment] where comm_id="&objrs("comm_id")&" and [comm_content] like '%url%'")
if err.number=-2147217900 then
'因为是on err继续 所以这里找到溢出的错误代码,这个是自己debug出来的,实际上不是从什么地方找的。
objconn.execute("update [blog_comment] set [comm_content]='"&filtersql(japan2html(objrs("comm_content")))&"',[comm_author]='"&filtersql(japan2dc9cnhtml(objrs("comm_author")))&"' where comm_id="&objrs("comm_id")&" ")
'这个就是把日文替换一下,思路是不是很巧妙。恩。不过数据库庞大的化,反复溢出就会很出问题的。内存宝宝会哭的。
err.clear
end if
objrs.movenext
next
end if
objrs.close
set objrs=nothing
'www.dc9.cn 07/11/28
end function
function japan2dc9cnhtml(source)
source=replace(source,"ガ","ガ")
source=replace(source,"ギ","ギ")
source=replace(source,"ア","ア")
source=replace(source,"ゲ","ゲ")
source=replace(source,"ゴ","ゴ")
source=replace(source,"ザ","ザ")
source=replace(source,"ジ","ジ")
source=replace(source,"ズ","ズ")
source=replace(source,"ゼ","ゼ")
source=replace(source,"ゾ","ゾ")
source=replace(source,"ダ","ダ")
source=replace(source,"ヂ","ヂ")
source=replace(source,"ヅ","ヅ")
source=replace(source,"デ","デ")
source=replace(source,"ド","ド")
source=replace(source,"バ","バ")
source=replace(source,"パ","パ")
source=replace(source,"ビ","ビ")
source=replace(source,"ピ","ピ")
source=replace(source,"ブ","ブ")
source=replace(source,"ブ","ブ")
source=replace(source,"プ","プ")
source=replace(source,"ベ","ベ")
source=replace(source,"ペ","ペ")
source=replace(source,"ボ","ボ")
source=replace(source,"ポ","ポ")
source=replace(source,"ヴ","ヴ")
japan2html=source
end function
顺便说一下,最近我的blog反复被hack,搞得我很郁闷,因为是阿拉伯人或者是以色列人干的,所以没法沟通。
我还找不出来他们是怎么干的。
真的很郁闷。
好了。
接下来的日子里。我将再发布一些技术性的文章。突然感到这个位子很宝贵的说。
google里面应该能找到我以前写的那个。就不说了。
后来某一天,我发现asp就能实现。我当时真的觉得自己太屎了。
不过asp的这种方法很不好。容易造成系统崩溃(如果数据库大)。
所以只是写在这里。算是抛砖引玉。
'下面我解释一下下:
function transferjapandc9cnindb()
on error resume next
err.clear
dim objrs,i
set objrs=server.createobject("adodb.recordset")
objrs.cursortype = adopenkeyset
objrs.locktype = adlockreadonly
objrs.activeconnection=objconn
objrs.source="select * from [blog_comment]"
objrs.open()
if (not objrs.bof) and (not objrs.eof) then
for i=1 to objrs.recordcount
'遍历,看看有没有日文,如果有,就溢出了,随便搜索一个东西就行了。搜什么无所谓。因为是遍历access只要指针移动到日文就溢出。
objconn.execute("select * from [blog_comment] where comm_id="&objrs("comm_id")&" and [comm_content] like '%url%'")
if err.number=-2147217900 then
'因为是on err继续 所以这里找到溢出的错误代码,这个是自己debug出来的,实际上不是从什么地方找的。
objconn.execute("update [blog_comment] set [comm_content]='"&filtersql(japan2html(objrs("comm_content")))&"',[comm_author]='"&filtersql(japan2dc9cnhtml(objrs("comm_author")))&"' where comm_id="&objrs("comm_id")&" ")
'这个就是把日文替换一下,思路是不是很巧妙。恩。不过数据库庞大的化,反复溢出就会很出问题的。内存宝宝会哭的。
err.clear
end if
objrs.movenext
next
end if
objrs.close
set objrs=nothing
'www.dc9.cn 07/11/28
end function
function japan2dc9cnhtml(source)
source=replace(source,"ガ","ガ")
source=replace(source,"ギ","ギ")
source=replace(source,"ア","ア")
source=replace(source,"ゲ","ゲ")
source=replace(source,"ゴ","ゴ")
source=replace(source,"ザ","ザ")
source=replace(source,"ジ","ジ")
source=replace(source,"ズ","ズ")
source=replace(source,"ゼ","ゼ")
source=replace(source,"ゾ","ゾ")
source=replace(source,"ダ","ダ")
source=replace(source,"ヂ","ヂ")
source=replace(source,"ヅ","ヅ")
source=replace(source,"デ","デ")
source=replace(source,"ド","ド")
source=replace(source,"バ","バ")
source=replace(source,"パ","パ")
source=replace(source,"ビ","ビ")
source=replace(source,"ピ","ピ")
source=replace(source,"ブ","ブ")
source=replace(source,"ブ","ブ")
source=replace(source,"プ","プ")
source=replace(source,"ベ","ベ")
source=replace(source,"ペ","ペ")
source=replace(source,"ボ","ボ")
source=replace(source,"ポ","ポ")
source=replace(source,"ヴ","ヴ")
japan2html=source
end function
顺便说一下,最近我的blog反复被hack,搞得我很郁闷,因为是阿拉伯人或者是以色列人干的,所以没法沟通。
我还找不出来他们是怎么干的。
真的很郁闷。
好了。
接下来的日子里。我将再发布一些技术性的文章。突然感到这个位子很宝贵的说。