use constant for encoding

same as 5f30b54, performance improvement