better encoding of data passed to PHP