Fixed bug in function for multibyte-safe truncation