ASP Chinese Pinyin to support custom special words

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

This update blog, will generate static files when the file name with the title of the text of the pinyin, which involves how to convert the word into pinyin, on the internet probably looked at, the same function, should only be normal under the GB2312, also did not do too much consideration, This took out the source of worry-free system has seen a section of the use.

Take a look at the following function and add a few comments: This is a function of a custom special word

the following references:


Function getenglish (ByVal Str)


getenglish = Str


getenglish = Replace (getenglish, "China", "Chinese")


getenglish = Replace (Getenglish, "Planning", "plan")


getenglish = Replace (Getenglish, "free", "freely")


getenglish = Replace (Getenglish, "Introduction", "Intro")


getenglish = Replace (Getenglish, "tricks", "skill")


getenglish = Replace (Getenglish, "Living", "life")


Getenglish = Replace (getenglish, "active", "activity")


getenglish = Replace (getenglish, tools, tool)


getenglish = Replace (getenglish, "Federation", "union")


getenglish = Replace (getenglish, "register", "register")


getenglish = Replace (Getenglish, "experience", "experience")


getenglish = Replace (getenglish, "translate", "translate")


getenglish = Replace (Getenglish, "item", "Item")


getenglish = Replace (getenglish, site, web-site)


getenglish = Replace (Getenglish, "English", "中文版")


getenglish = Replace (Getenglish, "English", "中文版")


getenglish = Replace (getenglish, Yahoo)


getenglish = Replace (Getenglish, "Sina", "Sina")


getenglish = Replace (Getenglish, "Alipay", "Alipay")


getenglish = Replace (getenglish, "Transaction", "Mini-advertisements")


getenglish = Replace (Getenglish, "Shop", "Business-to-consumer")


getenglish = Replace (getenglish, upgrade, update)


getenglish = Replace (Getenglish, Magazine, magazine)


getenglish = Replace (getenglish, "spaces", "space")


getenglish = Replace (Getenglish, "Love", "loving")


getenglish = Replace (Getenglish, "Friends", "friend")


getenglish = Replace (getenglish, "Friendship", "friend")


getenglish = Replace (getenglish, "link", "like")


Getenglish = Replace (getenglish, label, label)


getenglish = Replace (Getenglish, "Run", "Running")


getenglish = Replace (getenglish, admin, manager)


getenglish = Replace (getenglish, "admin", "manage")


getenglish = Replace (getenglish, pages, page)


getenglish = Replace (getenglish, template, template)


getenglish = Replace (Getenglish, "Game", "game")


getenglish = Replace (getenglish, Forum, Forum)


getenglish = Replace (Getenglish, press, News)


getenglish = Replace (Getenglish, "musical", "Music")


getenglish = Replace (getenglish, Assist, help)


Getenglish = Replace (getenglish, "optimization", "optimize")


getenglish = Replace (getenglish, "software", "soft")


getenglish = Replace (getenglish, tutorial, Tech)


getenglish = Replace (getenglish, "Download", "Download")


getenglish = Replace (getenglish, "Searching", "search")


getenglish = Replace (Getenglish, engine, engine)


getenglish = Replace (Getenglish, "spider", "spider")


getenglish = Replace (getenglish, logs, log)


getenglish = Replace (getenglish, "blog", "blog")


getenglish = Replace (Getenglish, "Baidu" and "Baidu")


getenglish = Replace (getenglish, "Google", "Google")


Getenglish = Replace (getenglish, "Mailbox", "Mailbox")


getenglish = Replace (Getenglish, "Mail", "Mail")


getenglish = Replace (getenglish, "Domain name", "Domain")


getenglish = Replace (getenglish, testing, test)


getenglish = Replace (Getenglish, demo, demo)


getenglish = Replace (Getenglish, "musical", "Music")


getenglish = Replace (Getenglish, "jokes", "joke")


getenglish = Replace (getenglish, products, product)


getenglish = Replace (getenglish, "Guestbook", "message")


getenglish = Replace (getenglish, "Feedback", "Freedback")


getenglish = Replace (getenglish, comments, comment)


Getenglish = Replace (Getenglish, "recommended", "commend")


getenglish = Replace (getenglish, shared, share)


getenglish = Replace (getenglish, resources, Resource)


getenglish = Replace (Getenglish, Plugins, plugins)


getenglish = Replace (Getenglish, "Notebook", "Notebook")


getenglish = Replace (getenglish, "Computer", "Computer")


getenglish = Replace (Getenglish, "systems", "system")


getenglish = Replace (Getenglish, "school", "parochial")


getenglish = Replace (Getenglish, "worry-free", "5u")


getenglish = Replace (getenglish, "work", "job")


getenglish = Replace (getenglish, info, info)


Getenglish = Replace (getenglish, "Entertainment", "ENT")


getenglish = Replace (getenglish, "Auto", "Car")


getenglish = Replace (getenglish, cell phone, mobile)


getenglish = Replace (getenglish, "network", "receptacle")


getenglish = Replace (getenglish, owner, boss)


getenglish = Replace (Getenglish, "dog", "dog")


getenglish = Replace (Getenglish, "TV", "TV")


getenglish = Replace (Getenglish, "movie", "movie")


End Function

And then the most critical function Pinyin (ByVal Chinese) He converts Chinese to pinyin

the following references:


function Pinyin (ByVal Chinese)


Chinese = replace (Chinese, "/", ""): Chinese = replace (Chinese, "\", "")


Chinese = replace (Chinese, "*", ""): Chinese = replace (Chinese, "]", "")


Chinese = replace (Chinese, "[", ""): Chinese = replace (Chinese, "}", "")


Chinese = replace (Chinese, "{", ""): Chinese = replace (Chinese, "'", "")


Chinese = getenglish (Chinese) ' uses Getenglish to convert special words first


Dim pinyinstr, Istr, IISCN, IsCn


Dim pinyinconn, RS, I, X


' Open Pinyin library here


' You can also incorporate the Pinyin library into your program database.


On Error Resume Next


Set pinyinconn = Server.CreateObject ("adodb.connection")


pinyinconn.open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("Pinyin. Asp ")


If err then pinyin = "": Set Pinyinconn = Nothing:exit function


IsCn = True


for i = 1 to Len (Chinese)


IISCN = IsCn ' Gets the last value that was not Chinese


ISTR = Mid (Chinese, I, 1)


x = ASC (ISTR)


if (x >= and X <=) or (x >= and x <= 122) or (x >= and x <=) or ISTR = "" Then


IsCn = False ' These are in English, numbers (reserved characters), not altered


If istr = "" Then Istr = "-"


Else


Set rs = Pinyinconn.execute ("select top 1 [Pinyin] from [pinyin] Where [content] like '%" & istr & "% ';")


If not rs.eof then


ISTR = LCase (rs (0)): IsCn = True ' Chinese


Else


IsCn = False


If istr = "" Then Istr = "Else Istr =" "' Converts a space to-, if it is a different character, clears the


End If


Rs.close:set rs = Nothing


End If


if Iiscn = IsCn then Pinyinstr = pinyinstr & istr Else Pinyinstr = pinyinstr & "-" & ISTR


pinyinstr = replace (PINYINSTR, "--", "-")


pinyinstr = replace (PINYINSTR, "__", "_")


Next


If Right (pinyinstr, 1) = "-" Then Pinyinstr = Left (Pinyinstr, Len (PINYINSTR)-1)


If Right (pinyinstr, 1) = "_" Then Pinyinstr = Left (Pinyinstr, Len (PINYINSTR)-1)


if left (pinyinstr, 1) = "-" Then Pinyinstr = Right (Pinyinstr, Len (PINYINSTR)-1)


if left (pinyinstr, 1) = "_" Then Pinyinstr = Right (Pinyinstr, Len (PINYINSTR)-1)


Pinyinconn.close


Set pinyinconn = Nothing


Pinyin = Trim (pinyinstr)


End Function

How to use:

the following references:


Response.Write Pinyin ("China Hello, Welcome to China!") ")

This method, converted to the phonetic format file name is very friendly to the SEO requirements of the small, you can try.

Pinyin database download annoyance ' s blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.