获取字符中中文首字字符

所属分类: 网络编程 / ASP编程 阅读数: 1384
收藏 0 赞 0 分享

复制代码 代码如下:

<%
'获取字符中中文首字字符
    '返回:A-Z ;123 ; ###
    Public Function GetSpellChar(str)
        Dim tmp
        GetSpellChar = "@"
        tmp = 65536 + Asc(str)
        If (tmp >= 45217 And tmp <= 45252) Or (tmp = 65601) Or (tmp = 65633) Or (tmp = 37083) Then
            GetSpellChar = "A1"
        ElseIf (tmp >= 45253 And tmp <= 45760) Or (tmp = 65602) Or (tmp = 65634) Or (tmp = 39658) Then
            GetSpellChar = "B1"
        ElseIf (tmp >= 45761 And tmp <= 46317) Or (tmp = 65603) Or (tmp = 65635) Or (tmp = 33405) Then
            GetSpellChar = "C1"
        ElseIf (tmp >= 46318 And tmp <= 46930) Or (tmp = 61884) Or (tmp = 63468) Or (tmp = 65604) Or (tmp >= 36820 
And tmp <= 38524) Or (tmp = 65636) Then
            GetSpellChar = "D1"
        ElseIf (tmp >= 46931 And tmp <= 47009) Or (tmp >= 46827 And tmp <= 46842) Or (tmp = 65605) Or (tmp = 65637) 
Or (tmp = 61513) Then '46827 46833 46842
            GetSpellChar = "E1"
        ElseIf (tmp >= 47010 And tmp <= 47296) Or (tmp = 65606) Or (tmp = 65638) Or (tmp = 61320) Or (tmp = 63568) Or 
(tmp = 36281) Then
            GetSpellChar = "F1"
        ElseIf (tmp >= 47297 And tmp <= 47613) Or (tmp = 65607) Or (tmp = 65639) Or (tmp = 35949) Or (tmp = 36089) Or 
(tmp = 36694) Or (tmp = 34808) Then
            GetSpellChar = "G1"
        ElseIf (tmp >= 47614 And tmp <= 48118) Or (tmp = 59112) Or (tmp = 40296) Or (tmp = 65608) Or (tmp = 65640) 
Then
            GetSpellChar = "H1"
        ElseIf (tmp = 65641) Or (tmp = 65609) Or (tmp = 65641) Then
            GetSpellChar = "I1"
        ElseIf (tmp >= 48119 And tmp <= 49061 And tmp <> 48739) Or (tmp >= 62430 And tmp <= 62430) Or (tmp = 65610) 
Or (tmp = 65642) Or (tmp = 39048) Then
            GetSpellChar = "J1"
        ElseIf (tmp >= 49062 And tmp <= 49323) Or (tmp = 65611) Or (tmp = 65643) Then
            GetSpellChar = "K1"
        ElseIf (tmp >= 49324 And tmp <= 49895) Or (tmp >= 58838 And tmp <= 58838) Or (tmp = 65612) Or (tmp = 65644) 
Or (tmp = 62418) Or (tmp = 48739) Then
            GetSpellChar = "L1"
        ElseIf (tmp >= 49896 And tmp <= 50370) Or (tmp = 63432) Or (tmp = 65613) Or (tmp = 65645) Then
            GetSpellChar = "M1"
        ElseIf (tmp >= 50371 And tmp <= 50613) Or (tmp = 65614) Or (tmp = 65646) Then
            GetSpellChar = "N1"
        ElseIf (tmp >= 50614 And tmp <= 50621) Or (tmp = 65615) Or (tmp = 65615) Or (tmp = 65647) Then
            GetSpellChar = "O1"
        ElseIf (tmp >= 50622 And tmp <= 50905) Or (tmp = 65616) Or (tmp = 65648) Then
            GetSpellChar = "P1"
        ElseIf (tmp >= 50906 And tmp <= 51386) Or (tmp >= 62659 And tmp <= 63172) Or (tmp = 63464) Or (tmp = 63226) 
Or (tmp = 65617) Or (tmp = 65649) Then
            GetSpellChar = "Q1"
        ElseIf (tmp >= 51387 And tmp <= 51445) Or (tmp = 65618) Or (tmp = 65650) Then
            GetSpellChar = "R1"
        ElseIf (tmp >= 51446 And tmp <= 52217) Or (tmp = 65619) Or (tmp = 65651) Or (tmp = 34009) Then
            GetSpellChar = "S1"
        ElseIf (tmp >= 52218 And tmp <= 52697) Or (tmp = 65620) Or (tmp = 65652) Then
            GetSpellChar = "T1"
        ElseIf (tmp = 65621) Or (tmp = 65653) Then
            GetSpellChar = "U1"
        ElseIf (tmp = 65622) Or (tmp = 65654) Then
            GetSpellChar = "V1"
        ElseIf (tmp >= 52698 And tmp <= 52979) Or (tmp = 65623) Or (tmp = 65655) Then
            GetSpellChar = "W1"
        ElseIf (tmp >= 52980 And tmp <= 53688) Or (tmp = 63182) Or (tmp = 65624) Or (tmp = 65656) Then
            GetSpellChar = "X1"
        ElseIf (tmp >= 53689 And tmp <= 54480) Or (tmp = 65625) Or (tmp = 65657) Then
            GetSpellChar = "Y1"
        ElseIf (tmp >= 54481 And tmp <= 62383 And tmp <> 59112 And tmp <> 58838 And tmp <> 57566) Or (tmp = 65626) Or 
(tmp = 65658) Or (tmp = 38395) Or (tmp = 39783) Then
            GetSpellChar = "Z1"
        End If
        If (tmp >= 65601 And tmp <= 65658) Then GetSpellChar = UCase(Left(Trim(str), 1)) '字母
        If (tmp >= 65584 And tmp <= 65593) Then GetSpellChar = "123" '数字
        'Response.Write(tmp)
    End Function
response.write GetSpellChar("脚")
response.write GetSpellChar("本")
response.write GetSpellChar("之")
%>

更多精彩内容其他人还在看

asp知识整理笔记4(问答模式)

这是关于asp知识整理的最后一份笔记,希望大家仔细阅读。
收藏 0 赞 0 分享

ASP基础知识VBScript基本元素讲解

这篇文章主要介绍了ASP基础知识VBScript基本元素的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP编码和解码函数详解

这篇文章主要介绍了ASP编码和解码函数的相关资料,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP显示页面执行时间的方法

这篇文章主要介绍了ASP显示页面执行时间的方法,在本地测试一下输出页面需要多少时间,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP基础入门第一篇(ASP技术简介)

本文将以 Active Server Pages 为中心,向你全面展示制作动态商业网站的步骤和技巧并通过大量的实例,让你在不断的理论和实践之中笑傲“网络”……
收藏 0 赞 0 分享

ASP基础入门第二篇(ASP基础知识)

这篇文章是ASP基础入门第二篇,第一篇展示了ASP动态网站设计的一些最基本的方法,相信通过实践各位对 ASP 已经有了最基本的了解,本文将进一步介绍ASP动态网站的一些基本技巧,需要的朋友可以参考下
收藏 0 赞 0 分享

ASP基础入门第三篇(ASP脚本基础)

通过前两篇的学习,相信各位已经对 ASP 的动态网站设计有了一个基本的概念和整体的印象。从本篇开始作者将从脚本语言的使用着手,由浅入深地带领大家探索 ASP 动态网站设计的真正奥秘。
收藏 0 赞 0 分享

ASP基础入门第四篇(脚本变量、函数、过程和条件语句)

大家在学习了脚本语言 VBScript 的变量、常量和过程的基本概念后,本期将继续向各位介绍 VBScript 的函数和语法。
收藏 0 赞 0 分享

ASP基础入门第五篇(ASP脚本循环语句)

在本文上两篇中,我们学习了脚本语言 VBScript 的变量、函数、过程和条件语句,本篇将继续给大家介绍 VBScipt 的循环语句,并对脚本语言在 ASP 中的应用加以总结。  
收藏 0 赞 0 分享

ASP基础入门第六篇(ASP内建对象Request)

从本篇开始作者从 ASP 内建对象着手,为大家详细剖析 ASP 的六个内建对象和各种组件的特性和方法,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多