Optimize UTFEncoderDecoder for issue #3483

I wouldn't split them up so much but this is my personal favor.