Copied truncate method to UIUtilities class