Recommended: Summary of 11 database syntax for ASP connection Operations related to databases are often used. It includes connection codes, SQL commands, etc., but I have never deliberately remembered them (I don’t want to remember this thing), so I often check the books and flip through them when I use them. Some less used databases may not be able to go smoothly
This time I updated the blog program I used to use, using the pinyin of the article title when generating static files. This involves how to convert text into pinyin. I took a look at it online. The same function should only be normal under GB2312, and I didn't think much about it. This shows a paragraph I saw in the source code of the Worry-free system and used it.
Let’s take a look at the following functions and add a few comments:
This is a function that customizes special words
| The following is the quoted content: Function getEnglish(ByVal Str) getEnglish = Str getEnglish = Replace(getEnglish, China, China) getEnglish = Replace(getEnglish, planning, plan) getEnglish = Replace(getEnglish, free, free ) getEnglish = Replace(getEnglish, introduction, intro ) getEnglish = Replace(getEnglish, skill, skill ) getEnglish = Replace(getEnglish, life, life) getEnglish = Replace(getEnglish, activity, activity) getEnglish = Replace(getEnglish, tool, tool) getEnglish = Replace(getEnglish, alliance, union) getEnglish = Replace(getEnglish, registration, register) getEnglish = Replace(getEnglish, experience, experience) getEnglish = Replace(getEnglish, translation, translate) getEnglish = Replace(getEnglish, project, item ) getEnglish = Replace(getEnglish, website, web-site) getEnglish = Replace(getEnglish, English, english) getEnglish = Replace(getEnglish, English, english) getEnglish = Replace(getEnglish, Yahoo, yahoo) getEnglish = Replace(getEnglish, Sina, sina) getEnglish = Replace(getEnglish, Alipay, alipay) getEnglish = Replace(getEnglish, transaction, trade) getEnglish = Replace(getEnglish, online store, b2c ) getEnglish = Replace(getEnglish, upgrade, update) getEnglish = Replace(getEnglish, magazine, magazine) getEnglish = Replace(getEnglish, space, space) getEnglish = Replace(getEnglish, love, love) getEnglish = Replace(getEnglish, friend, friend) getEnglish = Replace(getEnglish, friendship, friend) getEnglish = Replace(getEnglish, link, like ) getEnglish = Replace(getEnglish, label, label) getEnglish = Replace(getEnglish, run, running) getEnglish = Replace(getEnglish, management, manager) getEnglish = Replace(getEnglish, management, manage) getEnglish = Replace(getEnglish, page, page) getEnglish = Replace(getEnglish, template, template) getEnglish = Replace(getEnglish, game, game) getEnglish = Replace(getEnglish, forum, forum) getEnglish = Replace(getEnglish, news, news) getEnglish = Replace(getEnglish, music, music) getEnglish = Replace(getEnglish, help, help ) getEnglish = Replace(getEnglish, optimization, optimize) getEnglish = Replace(getEnglish, software, soft ) getEnglish = Replace(getEnglish, tutorial, tech) getEnglish = Replace(getEnglish, download, download) getEnglish = Replace(getEnglish, search, search) getEnglish = Replace(getEnglish, engine, engine) getEnglish = Replace(getEnglish, spider, spider) getEnglish = Replace(getEnglish, log, log) getEnglish = Replace(getEnglish, blog, blog) getEnglish = Replace(getEnglish, Baidu, 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, test, test) getEnglish = Replace(getEnglish, demo, demo) getEnglish = Replace(getEnglish, music, music) getEnglish = Replace(getEnglish, joke, joke) getEnglish = Replace(getEnglish, product, product) getEnglish = Replace(getEnglish, message, message) getEnglish = Replace(getEnglish, feedback, freedback) getEnglish = Replace(getEnglish, comment, comment) getEnglish = Replace(getEnglish, recommended, comment ) getEnglish = Replace(getEnglish, share, share) getEnglish = Replace(getEnglish, resource, resource) getEnglish = Replace(getEnglish, plugins, plugins) getEnglish = Replace(getEnglish, notebook, notebook) getEnglish = Replace(getEnglish, computer, computer) getEnglish = Replace(getEnglish, system, system) getEnglish = Replace(getEnglish, school, school) getEnglish = Replace(getEnglish, worry-free, 5u ) getEnglish = Replace(getEnglish, job, job) getEnglish = Replace(getEnglish, information, info) getEnglish = Replace(getEnglish, entertainment, ent ) getEnglish = Replace(getEnglish, car, car) getEnglish = Replace(getEnglish, mobile, mobile) getEnglish = Replace(getEnglish, network, network) getEnglish = Replace(getEnglish, boss, boss) getEnglish = Replace(getEnglish, dog, dog) getEnglish = Replace(getEnglish, TV, tv) getEnglish = Replace(getEnglish, movie, movie) End Function |
Then there is the most critical function pinyin(byval chinese) which converts Chinese to pinyin
| The following is the quoted content: 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) 'With getEnglish here, convert special words first dim pinyinstr, isr, iIsCn, IsCn dim pinyinconn, rs, i, x 'Open the 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 ' Get the value of whether it was last Chinese isr = Mid(chinese, i, 1) x = Asc(istr) if (x >= 65 and x <= 90) or (x >= 97 and x <= 122) or (x >= 48 and x <= 57) or isr = then IsCn = false ' These are English, numbers (reserved characters), without changing if itr = then itr = - else set rs = pinyinconn.execute(select Top 1 [pinyin] From [pinyin] Where [content] like '% & isr & %';) if not rs.eof then isr = lcase(rs(0)): IsCn = true ' Chinese else IsCn = false if itr = then itr = - else itr = ' Convert spaces to -, clear if it is another character end if rs.close: set rs = nothing end if if iIsCn = IsCn then pinyinstr = pinyinstr & isr else pinyinstr = pinyinstr & - & isr 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 is the quoted content: response.write pinyin (Hello, welcome to China!) |
This method is very friendly to the pinyin format file name. Xiaocheng who has requirements for SEO can try it.
Share: Introduction to Asp and five built-in objects Table 1. ASP Basics 2. Five major objects of ASP 3. Request object 4. Response object 5. Server object 6. Application object 7. Session object 1. ASP Basics Microsoft Active Server Pages, which readers and friends call it