make truncate function unicode capable