Unify encoding methods