- 227 名前:名無しさん@お腹いっぱい。 mailto:sage [04/05/29 16:17]
- (defun write-binaried-file (filename)
(interactive (list (read-file-name "Write file: " nil buffer-file-name nil buffer-file-name))) (let (i buf temp-buffer-show-hook) (with-output-to-temp-buffer " *outbuf*" (save-excursion (save-restriction (widen) (goto-char (point-min)) (while (re-search-forward "^\\([0-F]+\\): +\\(?:\\(?:[01]\\{8\\}\\) \\)\\{8\\}" nil t) (goto-char (match-end 1)) (setq i 0) (while (< i 8) (re-search-forward "[01]+") (princ (char-to-string (string-to-number (match-string 0) 2))) (setq i (1+ i)))) (if (re-search-forward "^\\([0-F]+\\): +\\([01]\\{8\\}\\) ") (progn (goto-char (match-beginning 2)) (setq i 0) (while (and (< i 8) (re-search-forward "\\=\\([01]\\{8\\}\\) " nil t)) (princ (char-to-string (string-to-number (match-string 1) 2))) (setq i (1+ i))))) (setq buf standard-output)))) (set-buffer buf) (let ((coding-system-for-write 'no-conversion)) (write-region (point-min) (point-max) filename)) (kill-buffer buf)))
|

|