adding multibyte space support to the truncate function