entity encode/decode for poly.js