grafted the new escape functions from rewrite-util