When escaping strings, ensure that intermediate has appropriate encoding, so we don't double encode.