encode format to enum