restore encoding after triming.