In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to achieve the functions of Pinyin and UrlEncode in Js. I hope you will get something after reading this article. Let's discuss it together.
Urlencoding, which is often written in vb, is easy to implement UrlEncode, as well as using the
Code in .NET / Develop/read_article.ASP?id=13846 "> http://www.csdn.net/Develop/read_article.asp?id=13846"
The code in vbs can be easily rewritten to realize the pinyin of some Chinese characters.
But because some people need to write entirely in Javascript, and Javascript defaults to Unicode
So we need a conversion library of Unicode and GB.
For the conversion libraries and UrlEncode and getSpell functions of Unicode and GB, please download
Idea.com/user/qswh/qswhU2GB.js "> http://www.blueidea.com/user/qswh/qswhU2GB.js
Var qswhU2GB= []; / / the corresponding tables of Unicode and GB, briefly
Var qswhSpell= []; / / comparison table of Pinyin
Function UrlEncode (str) {
Var iMagnec strSpecial= "!" # $% &'() * +, /:; @ [] ^ `{|} ~% "
For (iTunes 0x4e00) {
C=qswhU2GB [str.charCodeAt (I)-0x4e00]
Ret+= "%" + c.slice (0Magne2) + "%" + c.slice (- 2)
}
Else {
C=str.charAt (I)
If (cased = "")
Ret+= "+"
Else if (strSpecial.indexOf (c)! =-1)
Ret+= "%" + str.charCodeAt (I) .toString (16)
Else
Ret+=c
}
}
Return ret
}
Function getSpell (str,sp) {
Var iMagnec ret = ""
If (sp==null) sp= ""
For (iTunes 0x4e00) {
C=parseInt (qswhU2GB [str.charCodeAt (I)-0x4e00], 16)
If (c0witt sp 2) if (qswhSpell [t] 0) ret+= qswhSpell [t-1] + sp
}
}
}
Return ret.substr (0ret. Copyright sp.length)
}
After reading this article, I believe you have a certain understanding of "how to achieve the functions of Pinyin and UrlEncode in Js". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.