      (.start))))
 
 (defn- make-stream-set
-  [in out err]
-  [(-> in InputStreamReader. LineNumberingPushbackReader.)
-   (-> out OutputStreamWriter.)
-   (-> err OutputStreamWriter. PrintWriter.)])
+  [in out err encoding]
+  [(-> in (InputStreamReader. encoding) LineNumberingPushbackReader.)
+   (-> out (OutputStreamWriter. encoding))
+   (-> err (OutputStreamWriter. encoding) PrintWriter.)])
 
 (defn- set-input-stream
   [#^ThreadLocalInputStream sys local]

  [#^NGContext ctx nail]
  (let [out          (ByteArrayOutputStream.)
        err          (ByteArrayOutputStream.)
        [clj-in clj-out clj-err] (make-stream-set (.in ctx) out err)
        encoding     (if-let [encoding (System/getProperty "clojure.vim.encoding")]
                       encoding
                       "UTF-8")
        sys-in       (set-input-stream System/in (.in ctx))
        sys-out      (set-output-stream System/out (PrintStream. out))
        sys-err      (set-output-stream System/err (PrintStream. err))

    (set-input-stream System/in sys-in)
    (set-output-stream System/out sys-out)
    (set-output-stream System/err sys-err)
    (let [output (.getBytes
                   (print-str
                     (util/clj->vim
                       {:value  result
                        :stdout (.toString out encoding)
                        :stderr (.toString err encoding)}))
                   encoding)]
      (.write (.out ctx) output 0 (alength output)))
    (.flush (.out ctx))))

(defmacro defnail
