SUBSTRING(str,pos,len) returns too many characters when len > length(str), rather than stopping at the end of the string, as would be usual in most other implementations. (Albeit, for all I know, perhaps not in SQL.) In my discovery, chinese characters are returned.
If str is 20 characters then SUBSTRING(<field>,4,16) does the expected.
if str is less, it keeps going ... somewhere.
Sadly, I couldn't do SUBSTRING(<field>,4,MAX(LENGTH(<field>,16))). And no IF in file functions either.
OpenOffice 3.3.1 on Windows