推荐:解读用asp编写类似搜索引擎功能的代码首先建一个 access 数据库 ,库中有一个URLINDEX表,其中URL和Keywords字段分别添加了索引,如下: URL 文本(索引:有(无重复)) Title文本 Description文本 Summary文本 Keywords文本(索引:有(无重复)) 程序文件doquery.asp,代码: HTMLHEADTITLE简单搜索引擎
我们经常看到直接用left截字符串时,因为标题中会出现汉字和英文共存,所以造成两条新闻标题长度不一,为了解决这个问题我们可以使用下面这个函数。<% ’************************************************** ’函数名:gotTopic ’作用:截字符串,汉字一个算两个字符,英文算一个字符 ’参数:str----原字符串 ’strlen----截取长度 ’返回值:截取后的字符串 ’Copyright:asp教程 ’************************************************** FunctiongotTopic(ByValstr,ByValstrlen) Ifstr=Then gotTopic= ExitFunction EndIf Diml,t,c,i,strTemp str=Replace(Replace(Replace(Replace(str,,),,Chr(34)),>,>),<,<) l=Len(str) t=0 strTemp=str strlen=CLng(strlen) Fori=1Tol c=Abs(Asc(Mid(str,i,1))) Ifc>255Then t=t+2 Else t=t+1 EndIf Ift>=strlenThen strTemp=Left(str,i) ExitFor EndIf Next IfstrTemp<>strThen strTemp=strTemp&… EndIf gotTopic=Replace(Replace(Replace(Replace(strTemp,,),Chr(34),),>,>),<,<) EndFunction %> <% str=一共11111w有汉字 str1=一共有五汉字 response.writegotTopic
response.writegotTopic(str,10)& &gotTopic(str1,10)&
response.writeleft
response.writeLeft(str,5)& &Left(str1,5) response.end %> |
分享:揭秘解决杀毒软件误删asp文件的方法一些杀毒软件经常会把某些asp文件当成病毒删除,有时简直防不胜防,程序莫名其妙的就不能用了,因为少了文件呀~~。这主要是因为,杀毒软件将某些asp代码当成木马关键词,记录保存着,所以遇到有这个关键词,就会禁止运行或删除。 解决的方法是将这些关键词给