We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3548415 commit 4975d57Copy full SHA for 4975d57
chgCase.js
@@ -0,0 +1,34 @@
1
+/**
2
+ * @description 全角半角转换
3
+ * @author 未知
4
+ */
5
+
6
+//iCase: 0全到半,1半到全,其他不转化
7
+function chgCase(sStr,iCase){
8
+ if(typeof sStr != "string" || sStr.length <= 0 || !(iCase === 0 || iCase == 1)){
9
+ return sStr;
10
+ }
11
+ var i,oRs=[],iCode;
12
+ if(iCase){/*半->全*/
13
+ for(i=0; i<sStr.length;i+=1){
14
+ iCode = sStr.charCodeAt(i);
15
+ if(iCode == 32){
16
+ iCode = 12288;
17
+ }else if(iCode < 127){
18
+ iCode += 65248;
19
20
+ oRs.push(String.fromCharCode(iCode));
21
22
+ }else{/*全->半*/
23
24
25
+ if(iCode == 12288){
26
+ iCode = 32;
27
+ }else if(iCode > 65280 && iCode < 65375){
28
+ iCode -= 65248;
29
30
31
32
33
+ return oRs.join("");
34
+}
0 commit comments