Added encode option to string helper