This supports emacs input method within emacs session (with -nw option).
you can add the following code to you .emacs file.

;; let emacs's input method (quail) can work with hanterm while 
;; emacs's running withing hanterm.
;; crisp@cair.kaist.ac.kr
(when (and (not window-system) (getenv "HTICMD"))
  (call-process "sh" nil nil nil "-c" (getenv "HTICMD"))
  (add-hook 'kill-emacs-hook
            (function
             (lambda () (interactive)
               (call-process "sh" nil nil nil "-c" (getenv "HTICMD")))))
  (add-hook 'suspend-hook
            (function
             (lambda ()
               (interactive)
               (call-process "sh" nil nil nil "-c" (getenv "HTICMD")))))

  (add-hook 'suspend-resume-hook
            (function
             (lambda ()
               (interactive)
               (call-process "sh" nil nil nil "-c" (getenv "HTICMD"))
               (message "Resetting input method... done")))))

