new encoding API