utf: Add an encode that takes a buffer as an argument.