Add a utility method to truncate string to specific length.