Looks like the stringstrings package can do this:
\substring{This is a string.}{1}{4}
gives This, but it seems to be failed for non-ASCII characters:
\substring{这是一个句子。}{1}{4}
cannot give 这是一个.
Is there a similar package working for Chinese characters?

XeLaTeX, withxecjk,xunicode,fontspecpackages used, thanks. – oaheix May 16 '18 at 11:43stringstringspackage is not sufficiently utf8-aware. (The package's user guide says that it can handle some 2-byte-encoded characters; however, that's not full utf8-awareness.) – Mico May 16 '18 at 12:10