Using Perl intercept strings, the string contains Chinese, English, numbers, and various symbols, also contain Chinese punctuation, intercepting a certain number of characters, and the Chinese is complete after interception, and there will be no garble or question marks. Sub Makelen ($$) {MY ($ SSTR, $ SLEN) = @ _; MY $ Makelen, $ Parity; $ mslen = length ($ sstr); if ($ mn> $ SLEN) {for ($ mn = 0 $ mn <$ slen; $ mn ) # {$ s = SUBSTR ($ SSTR, $ Mn, 1); if ($ ss) <127) # {$ Parity = 1; }}} IF ($ PARITY% 2 == 1) # 奇 英 奇 奇 {{IF ($ SLEN% 2 == 1) # If the required length is also odd odder {$ Tmpstr = Substr ($ sstr, 0, $ The length required for ELSE # is even {$ Tmpstr = SubStr ($ sstr, 0, $ slen-1);}}}} ELSE # Contains English length or 0,0 is also even {IF ($ SLEN% 2 == 1) # If the required length is odd odder {$ Tmpstr = Substr ($ SSTR, 0, $ SLEN-1);} Else # The length required for Else # is even {$ Tmpstr = Substr ($ SSTR, 0, $ SLEN);}} $ makelen = $ tmpst r;} else {$ Makelen = $ sstr;} Return $ Makelen;