2007年2月8日 10:20
一直用php编写程序,哪里知道现在却需要在asp上搞一些东西,很是郁闷的东西很多,比如php对数组完美的几乎无懈可击,asp中对数据库的操作。。。。原汁原味的程序很少,都是要自己去编,你说累不累?
前几天一个项目需要增加排序,写了一个sort,但是没有对中文的排序功能,没有办法,总结下吧,思路也异常简单,中文转换成拼音,然后利用拼音排序。在本人测试的过程中,感觉还是相当完美的,getpychar这个函数也可以单独作为他用,在本人而然测试过程中发现了一个错误,是由多音字出现的,比如:重庆,在该函数里面分不清楚是读 ‘zhong’ 还是读‘chong’,这个估计也比较难解决。。。。如果各位大叔有办法,请回复。谢谢。
前几天一个项目需要增加排序,写了一个sort,但是没有对中文的排序功能,没有办法,总结下吧,思路也异常简单,中文转换成拼音,然后利用拼音排序。在本人测试的过程中,感觉还是相当完美的,getpychar这个函数也可以单独作为他用,在本人而然测试过程中发现了一个错误,是由多音字出现的,比如:重庆,在该函数里面分不清楚是读 ‘zhong’ 还是读‘chong’,这个估计也比较难解决。。。。如果各位大叔有办法,请回复。谢谢。
''*** Function that get pychar
function getpychar(char)
Dim tmp
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53640) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=62289) then
getpychar= "Z"
else '如果不是中文,则不处理
getpychar=char
end if
end function
function getpy(str)
dim i
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
end function
''*** Sorter Function that takes an array and sorts it
Function Sort(ary)
Dim KeepChecking,i,FirstValue,SecondValue
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For i = 0 to UBound(ary)
If i = UBound(ary) Then Exit For
If getpy(ary(i)) > getpy(ary(i+1)) Then
FirstValue = ary(i)
SecondValue = ary(i+1)
ary(i) = SecondValue
ary(i+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
Sort = ary
End Function
function getpychar(char)
Dim tmp
tmp=65536+asc(char)
if(tmp>=45217 and tmp<=45252) then
getpychar= "A"
elseif(tmp>=45253 and tmp<=45760) then
getpychar= "B"
elseif(tmp>=45761 and tmp<=46317) then
getpychar= "C"
elseif(tmp>=46318 and tmp<=46825) then
getpychar= "D"
elseif(tmp>=46826 and tmp<=47009) then
getpychar= "E"
elseif(tmp>=47010 and tmp<=47296) then
getpychar= "F"
elseif(tmp>=47297 and tmp<=47613) then
getpychar= "G"
elseif(tmp>=47614 and tmp<=48118) then
getpychar= "H"
elseif(tmp>=48119 and tmp<=49061) then
getpychar= "J"
elseif(tmp>=49062 and tmp<=49323) then
getpychar= "K"
elseif(tmp>=49324 and tmp<=49895) then
getpychar= "L"
elseif(tmp>=49896 and tmp<=50370) then
getpychar= "M"
elseif(tmp>=50371 and tmp<=50613) then
getpychar= "N"
elseif(tmp>=50614 and tmp<=50621) then
getpychar= "O"
elseif(tmp>=50622 and tmp<=50905) then
getpychar= "P"
elseif(tmp>=50906 and tmp<=51386) then
getpychar= "Q"
elseif(tmp>=51387 and tmp<=51445) then
getpychar= "R"
elseif(tmp>=51446 and tmp<=52217) then
getpychar= "S"
elseif(tmp>=52218 and tmp<=52697) then
getpychar= "T"
elseif(tmp>=52698 and tmp<=52979) then
getpychar= "W"
elseif(tmp>=52980 and tmp<=53640) then
getpychar= "X"
elseif(tmp>=53689 and tmp<=54480) then
getpychar= "Y"
elseif(tmp>=54481 and tmp<=62289) then
getpychar= "Z"
else '如果不是中文,则不处理
getpychar=char
end if
end function
function getpy(str)
dim i
for i=1 to len(str)
getpy=getpy&getpychar(mid(str,i,1))
next
end function
''*** Sorter Function that takes an array and sorts it
Function Sort(ary)
Dim KeepChecking,i,FirstValue,SecondValue
KeepChecking = TRUE
Do Until KeepChecking = FALSE
KeepChecking = FALSE
For i = 0 to UBound(ary)
If i = UBound(ary) Then Exit For
If getpy(ary(i)) > getpy(ary(i+1)) Then
FirstValue = ary(i)
SecondValue = ary(i+1)
ary(i) = SecondValue
ary(i+1) = FirstValue
KeepChecking = TRUE
End If
Next
Loop
Sort = ary
End Function
我们推荐您
快去试试吧!
E2支持的视频格式及各项参数标准表
怎样提取图片中的文字







