[topic] 文字コードの変換
Posted feedbacks - Common Lisp
よく知らなかったので調べながら……
文字列の変換は shiro さんの #4628 と同様にバイト列の変換にしています。ファイル入出力の際は :external-format を指定することで文字コード指定ができます。
いずれも処理系依存です。CLISP 2.38 で動作確認しました。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ;;; 1
(defun sjis-to-euc-jp (bytes)
(convert-string-to-bytes
(convert-string-from-bytes bytes charset:shift-jis)
charset:euc-jp))
;;; 2
(defun sjis-to-euc-jp-file (from to)
(with-open-file (in from :direction :input
:external-format charset:shift-jis)
(with-open-file (out to :direction :output
:external-format charset:euc-jp)
(do () ((null (listen in)))
(write-line (read-line in) out)))))
|



ところてん
#4620()
Rating1/1=1.00
[ reply ]