encode and decode unicode characters