consistently escape before encoding