added function trim

added trim to remove duplicate characters in charset