Support multi-byte characters in trim functions

Support multi-byte characters in trim functions.