processing: refactor character encoding and apply to singlehtml processor