Use encode instead of escape.
Add test for encode.