Encode persistenceIds into legal character set