Google Keyword Decoding Function

xiaoxiao2021-04-06  277

When doing a website statistics, sometimes you want to count keywords from Google, you have to decode Google Keywords. This function can be implemented as follows.

<% Function UTF2GB (UTFSTR) for Dig = 1 To Len (Utfstr) IF MID (Utfstr, DIG, 1) = "%" THEN IF LEN (Utfstr)> = Dig 8 Then GBSTR = GBSTR & ConvChinese (MID (Utfstr , DIG, 9)) DIG = DIG 8 Else GBSTR = GBSTR & MID (Utfstr, DIG, 1) Endiff else GBSTR = GBSTR & MID (Utfstr, DIG, 1) end if next uTF2GB = GBSTR End Function Function Convchine x) a = split (MID (x, 2), "%") i = 0 J = 0 for i = 0 to Ubound (a) a (i) = C16TO2 (A (i)) Next for i = 0 TO Ubound (a) -1 digs = INSTR (A (i), "0") Unicode = "" For J = 1 to DIGS-1 IF J = 1 THEN A (i) = Right (A (i), LEN (A (i)) - DIGS) Unicode = Unicode & A (i) ELSE i = i 1 a (i) = Right (a (i), len (a (i)) - 2) unicode = unicode & a (i) end if next if len (c2to16 (unicode)) =

4 THEN CONVCHINESE = CONVCHINESE & ChRW (INT ("& H")))) Else ConvChinese = ConvChinese & Chr (INT ("& H" & C2TO16 (Unicode)) End if Next End Function Function C16TO2 (X) I = 0 for i = 1 to len (Trim (x)) Tempstr = C10to2 (CINT (INT ("& H" & MID (X, I, 1)))) DO While Len (Tempstr) <4 tempstr = "0" & Tempstr Loop C16TO2 = C16TO2 & TEMPSTR NEXT END FUNCTION FUNCTION C10TO2 (x) mysign = SGN (X) x = ABS (x) DIGS = 1 DO IF x <2 ^ DIGS THEN EXIT DO ELSE DIGS = DIGS 1 End if loop Tempnum = x i = 0 for i = DIGS TO 1 Step-1 if Tempnum> = 2 ^ (i-1) TEMPNUM = Tempnum-2 ^ (i-1) C10to2 = C10to2 & "1" ELSE C10to2 = C10to2 & "0" End if next if mysign = -1 TEN C10TO2 = "-" & C10to2 End Function Function C2TO16 (X) i = 1 for i = 1 to Len (x) Step 4 C2to16 =

转载请注明原文地址:https://www.9cbs.com/read-132346.html

New Post(0)