encoder: improve string encoding code
test: make them async
encoder: fix too greedy escaping
test: add encoder escaping options tests