>데이터 베이스 >MySQL 튜토리얼 >检查有日文片假名的新闻

检查有日文片假名的新闻

WBOY
WBOY원래의
2016-06-07 15:05:121572검색

==26个 日文 片假名 导致Access搜索(80040e14/内存溢出)的解决办法== ゴ ガ ギ グ ゲ ザ ジ ズ ヅ デ ド ポ ベ プ ビ パ ヴ ボ ペ ブ ピ バ ヂ ダ ゾ ゼ 当字段内包含了这26个 日文 字符任意一个多个时,就会导致在执行SQL语句中包含了 [字段] like %aaaaa%

==26个日文片假名导致Access搜索(80040e14/内存溢出)的解决办法==

ゴ ガ ギ グ ゲ ザ ジ ズ ヅ デ ド ポ ベ プ ビ パ ヴ ボ ペ ブ ピ バ ヂ ダ ゾ ゼ
当字段内包含了这26个日文字符任意一个多个时,就会导致在执行SQL语句中包含了
[字段] like %aaaaa% 或 inStr(1,[字段],aaaaa,1)>0
这样的查询时,毫无道理的出现了
"Microsoft JET Database Engine 错误 80040e14 内存溢出"的错误
其他Jet SQL函数命令未作测试,大概与字符搜索定位匹配相关的都可能出错

搜索相关资料得知被微软工程师证实是Access的bug,可能是语法关系都是微软的东东
在vbs中 执行inStr(1,日文平假名变量,"aaaaa",1)依然要出现错误
Microsoft VBScript 运行时错误 错误 800a0005 无效的过程调用或参数: instr


没有搜索,因这几个字符出现Access的论坛网站搜索无法进行,何等痛苦
昨天一朋友大叫怪事,他的音乐数据库无法搜索了,只有30000条记录时是好的
毫无疑问,日文片假名是祸根,花几分钟把有包含上面的日文替换成"?"搜索顺利恢复
找来论坛程序用户群最大的动网dvBBS AC版本 7.0SP2 版测试,同样有这个日文发帖后 导致无法搜索并且运行时出错的问题
线上去搜索 80040e14 内存溢出" 的错误 多的是!

一简单有效的解决办法:
对这26个字符进行编码和解码,可能效率感觉不理想,测试下来问题不大,速度影响不是太大

编码:

Function Jencode(byVal iStr)
if isnull(iStr) or isEmpty(iStr) then
Jencode=""
Exit function
end if
dim F,i,E
F=array("ゴ","ガ","ギ","グ","ゲ","ザ","ジ","ズ","ヅ","デ",_
"ド","ポ","ベ","プ","ビ","パ","ヴ","ボ","ペ","ブ","ピ","バ",_
"ヂ","ダ","ゾ","ゼ")
E=array("Jn0;","Jn1;","Jn2;","Jn3;","Jn4;","Jn5;","Jn6;","Jn7;","Jn8;","Jn9;","Jn10;","Jn11;","Jn12;","Jn13;","Jn14;","Jn15;","Jn16;","Jn17;","Jn18;","Jn19;","Jn20;","Jn21;","Jn22;","Jn23;","Jn24;","Jn25;")
F=array(chr(-23116),chr(-23124),chr(-23122),chr(-23120),_
chr(-23118),chr(-23114),chr(-23112),chr(-23110),_
chr(-23099),chr(-23097),chr(-23095),chr(-23075),_
chr(-23079),chr(-23081),chr(-23085),chr(-23087),_
chr(-23052),chr(-23076),chr(-23078),chr(-23082),_
chr(-23084),chr(-23088),chr(-23102),chr(-23104),_
chr(-23106),chr(-23108))
Jencode=iStr
for i=0 to 25
Jencode=replace(Jencode,F(i),E(i))
next
End Function

解码:

Function Juncode(byVal iStr)
if isnull(iStr) or isEmpty(iStr) then
Juncode=""
Exit function
end if
dim F,i,E
F=array("ゴ","ガ","ギ","グ","ゲ","ザ","ジ","ズ","ヅ","デ",_
"ド","ポ","ベ","プ","ビ","パ","ヴ","ボ","ペ","ブ","ピ","バ",_
"ヂ","ダ","ゾ","ゼ")
E=array("Jn0;","Jn1;","Jn2;","Jn3;","Jn4;","Jn5;","Jn6;","Jn7;","Jn8;","Jn9;","Jn10;","Jn11;","Jn12;","Jn13;","Jn14;","Jn15;","Jn16;","Jn17;","Jn18;","Jn19;","Jn20;","Jn21;","Jn22;","Jn23;","Jn24;","Jn25;")
F=array(chr(-23116),chr(-23124),chr(-23122),chr(-23120),_
chr(-23118),chr(-23114),chr(-23112),chr(-23110),_
chr(-23099),chr(-23097),chr(-23095),chr(-23075),_
chr(-23079),chr(-23081),chr(-23085),chr(-23087),_
chr(-23052),chr(-23076),chr(-23078),chr(-23082),_
chr(-23084),chr(-23088),chr(-23102),chr(-23104),_
chr(-23106),chr(-23108))
Juncode=iStr
for i=0 to 25
Juncode=replace(Juncode,E(i),F(i))□
next
End Function

注意,如果直接使用字符不方便(windows还没装日文支持),注释掉的部分提供有 chr(-23804) ..这样的定义

新闻3页,当前在第1页  1  2  3  


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.