Author: caocao
PHP
Function isgb ($ code) {if (Strlen ($ code)> = 2) {$ code = strtok ($ code, ""); if (($ code [0]) <161) || (ORD $ CODE [0])> = 247)) {RETURN (0);} else {ix (($ code [1]) <= 161) || (ORD ($ Code [1])> = 254) ) {RETURN (0);}}}} else}}} else {return (1);}} function gboffset ($ code) {ix (Strlen> = 2) {$ code = strtok ($ CODE, ""); RETURN (($ code [0]) - 161) * 94 (ORD ($ code [1]) - 161));} else {return (-1);}} Function WordTostring ($ CODE) {RETURN (HEXDEC (Substr ($ CODE, 0, 2))))). CHR (HEXDEC (Substr ($ Code, 2, 2)))))));} Function GBTOBIG5 ($ CODE) { INCLUDE "DATA_GB.PHP"; $ OTPUT = ""; $ length = Strlen ($ code); $ code = strtok ($ code, "); $ IDX = 0; While ($ IDX <$ length) {$ TMPSTR = $ CODE [$ IDX 1]; if (ISGB ($ TmpStr)) {$ offset = gboffset ($ tmpswstr); if (($ offet> = 0) || ($ OFFSET < = 8177)) {$ output. = WordTostring ($ GBORDER [$ OFFSET]); $ IDX ;} Else {$ output. = $ Code [$ ID];} else {$ output. = $ Code [$ IDX];} $ IDX ;} return ($ output);};
How to use: 1. Save the above code as GBTOBIG5.PHP
2. Introduce GBTOBIG5.PHP in need
3. For the target field set function, implement the formatting output