Character encoding maps characters to byte sequences and decodes byte sequences back into characters. In Clojure I/O, an encoding controls how readers interpret input and writers produce output. section 22.8
Use the :encoding option when the resource uses something other than the default UTF-8. The chosen encoding must match the file’s actual encoding; specifying UTF-16 for another format is incorrect. section 22.8
Reading and writing UTF-16
(with-open [r (io/reader "/usr/share/dict/words" :encoding "UTF-16") w (io/writer "/tmp/words" :append true :encoding "UTF-16")] (doseq [line (line-seq r)] (.write w (str (upper-case line) "\n")))) ;; Processes lines lazily and appends UTF-16 output. section 22.8
(with-open [r (reader "/usr/share/dict/words" :encoding "UTF-16")
w (writer "/tmp/words" :append true :encoding "UTF-16")] ; #1
(doseq [line (line-seq r)]
(.write w (str (upper-case line) "\n")))) ; #2
Browse the complete UTF-16 reader-and-writer example, including append behavior and line processing. section 22.8



