Chinese Chinese character intercepting function (support GB2312, BIG5, UTF-8)

zhaozj2021-02-16  52

This is a Chinese Chinese character intercept function in the past few days because the project needs to be written:

= 3 ) {IF ($ ar [0])> $ flen) {Return Join ("", Array_Slice ($ AR [0], $ FSTART, $ FLEN)). "...";} returnjin (" ", Array_Slice ($ AR [0], $ FSTART, $ FLEN);} else {returnjin (" ", array_slice ($ ar [0), $ fstart);} Break; Default: $ fstart = $ fstart * 2; $ flen = $ flen * 2; $ Strlen = Strlen ($ fstr); for ($ I = 0; $ I = $ FSTART && $ I <($ FSTART

$ flen) {IF (Substr ($ FSTR, $ I, 1))> 129) $ TMPSTR. = Substr ($ FSTR, $ I, 2); Else $ TMPSTR. = Substr ($ FSTR, $ I , 1);} IF (Substr ($ FSTR, $ I, 1))> 129) $ i ;} IF (Strlen ($ Tmpstr) $ TMPSTR. = "..."; Return $ Examples of use:}}?>

"; echo "b =" .mstr ($ B, 0, 5, "UTF-8"). "
";?>

The output results are "one or two three four five ...", if there is a Chinese and English mixed, there will be only a problem that only the Chinese character half-character characters.

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

New Post(0)