encode and rtl js fixes