Kanji conversion to UTF-8function chinese2unicode (Str) dim i dim Str_one dim Str_unicode for i = 1 to len (Str) Str_one = Mid (Str, i, 1) Str_unicode = Str_unicode & chr (38) Str_unicode = Str_unicode & chr (35) Str_unicode = Str_unicode & chr (120) STR_UNICODE = STR_UNICODE & HEX (ASCW (STR_ONE)) STR_UNICODE = STR_UNICODE & CHR (59) Next Response.Write Str_unicore End Function
UTF-8 TO GB2312Function 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) end if else GBSTR = GBSTR & MID (Utfstr, DIG, 1) end if Next UTF2GB = GBSTREND FUNCTION FUNCTION CONVCHINESE (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 "& C2TO16 (Unicode)) ELSE CONVCHINESE = CONVCHINESE & CHR (INT (" & H "& C2TO16 (Unicode)) End if Nextend FunctionFunction C2TO16 (X) i = 1 for i = 1 to Len (x) Step 4 C2TO16 = C2TO16 & HEX (C2TO10 (MID (X, I, 4))) NEXTEND FUNCTION FUNCTION C2TO10 (X) C2TO10 = 0 IF x = "0" THEN EXIT FUNCTION I = 0 for i = 0 to len (x) - 1 IF MID (X, LEN (X) -i, 1) = "1" THEN C2TO10 = C2TO10 2 ^ (i) Next End FunctionFunction 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 NEXTEND FUNCTIONFUNCTION 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 THEN C10TO2 = "-" & C10to2nd functionFunction convChinese (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" & C2TO16 (Unicode))) ELSE CONVCHINESE = CONVCHINESE & CHR (INT ("& H" & C2TO16 (Unicode)) End if Nextend FunctionFunction C2TO16 (X) i = 1 for i = 1 To LEN (X) Step 4 C2TO16 = C2TO16 &