improved and added optional flags argument to engine.string.escape()