pick encoding smarter, and have a fallback to UTF-8