Remove duplicate code by adding a flag for encoding in verbatim mode.