Extract various string, encoding, and formatting logic from config
See branch `format_refactor`, with PR at https://github.com/torproject/tor/pull/190
issue