アットウィキロゴ

xyzzy

xyzzyの使い方メモになります。



バイナリファイルに書き込み

with-open-fileのオプションで:encoding :binaryを指定します。
バイナリデータへの変換はcode-charを使用します。

例)
H'00~H'FFのデータを書き出してみる。
(with-open-file (out "test.bin" :direction :output :if-exist :supersede :encoding :binary)
  (dotimes (n 256)
	(write-char (code-char n) out)))



バイナリファイルの読み出し

例)
上の「バイナリファイルに書き込み」で作成したファイルを
読み出して表示してみる。
(with-open-file (in "test.bin" :encoding :binary)
  (let ((ch))
	(while (setf ch (read-char in nil))
	  (print (char-code ch)))))



ハッシュテーブルの中身を全部表示する

maphash関数を使用します。
例)
エンコード種類のハッシュテーブルの中身を表示してみる。
(let ((alist nil))
  (maphash #'(lambda (x y) (print (cons x y))) *mime-charset-name-hash-table*)
  alist)
最終更新:2010年06月07日 02:28
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。