Added support to set the encoding direction