(ccl-execute-on-string): Too few args.
[elisp/apel.git] / emu-mule.el
index 8384501..6af919f 100644 (file)
@@ -156,7 +156,7 @@ automatic uncompression, etc.
 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)
     ))
 
@@ -210,6 +210,20 @@ find-file-hooks, etc.
       ))
   )
 
+(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
 ;;;
@@ -221,9 +235,9 @@ find-file-hooks, etc.
        (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*)
       )))
@@ -235,9 +249,9 @@ find-file-hooks, etc.
        (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)))
@@ -277,7 +291,10 @@ find-file-hooks, etc.
     (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))))
       )))
 
 
@@ -363,12 +380,11 @@ but the contents viewed as characters do change.
 
 (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)
     ))