Namely this function ensures that only format decoding and character
code conversion will not take place."
(let (mc-flag
- (file-coding-system *noconv*))
+ (file-coding-system-for-read *noconv*))
(insert-file-contents filename visit beg end replace)
))
))
)
+(defun write-region-as-raw-text-CRLF (start end filename
+ &optional append visit lockname)
+ "Like `write-region', q.v., but don't code conversion."
+ (let ((the-buf (current-buffer)))
+ (with-temp-buffer
+ (insert-buffer-substring the-buf start end)
+ (goto-char (point-min))
+ (while (re-search-forward "\\(\\=\\|[^\r]\\)\n" nil t)
+ (replace-match "\\1\r\n")
+ )
+ (write-region-as-binary (point-min)(point-max)
+ filename append visit lockname)
+ )))
+
;;; @ MIME charset
;;;
(code-convert start end *internal* cs)
)))
-(defun decode-mime-charset-region (start end charset)
+(defun decode-mime-charset-region (start end charset &optional lbt)
"Decode the text between START and END as MIME CHARSET."
- (let ((cs (mime-charset-to-coding-system charset)))
+ (let ((cs (mime-charset-to-coding-system charset lbt)))
(if cs
(code-convert start end cs *internal*)
)))
(code-convert-string string *internal* cs)
string)))
-(defun decode-mime-charset-string (string charset)
+(defun decode-mime-charset-string (string charset &optional lbt)
"Decode the STRING which is encoded in MIME CHARSET."
- (let ((cs (mime-charset-to-coding-system charset)))
+ (let ((cs (mime-charset-to-coding-system charset lbt)))
(if cs
(decode-coding-string string cs)
string)))
(if (or (null lbt)
(null cs))
cs
- (intern (concat (symbol-name cs) (symbol-name lbt)))
+ (intern (format "%s%s" cs (cond ((eq lbt 'CRLF) 'dos)
+ ((eq lbt 'LF) 'unix)
+ ((eq lbt 'CR) 'mac)
+ (t lbt))))
)))
(defun split-char (character)
"Return list of charset and one or two position-codes of CHARACTER."
- (let ((len (char-bytes character))
- (i 0)
+ (let ((p (1- (char-bytes character)))
dest)
- (while (< i len)
- (setq dest (cons (char-component character i) dest)
- i (1+ i))
+ (while (>= p 1)
+ (setq dest (cons (- (char-component character p) 128) dest)
+ p (1- p))
)
(cons (char-charset character) dest)
))