Substring in vim script
For multi-bytes characters, there is also :h strcharpart()
If the function does not exist in your old flavour of Vim, it could be emulated with for instance
function! lh#encoding#strpart(mb_string, p, l)
" call lh#assert#value(lh#encoding#strlen(a:mb_string)).is_ge(a:p+a:l)
return matchstr(a:mb_string, '.\{,'.a:l.'}', 0, a:p+1)
endfunction
it works like python:
echo '0123456'[2:4]
234
For detailed doc:
:h expr-[:]