Mercurial > emacs
comparison lisp/gnus/mm-util.el @ 61434:6d07c19816b9
(mm-string-to-multibyte): New function.
(mm-detect-coding-region): Typo.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 10 Apr 2005 19:04:09 +0000 |
parents | ad05d91d3598 |
children | 6cf26dc690b2 |
comparison
equal
deleted
inserted
replaced
61433:74a256d5f3ec | 61434:6d07c19816b9 |
---|---|
70 (aset string idx to)) | 70 (aset string idx to)) |
71 (setq idx (1+ idx))) | 71 (setq idx (1+ idx))) |
72 string))) | 72 string))) |
73 (string-as-unibyte . identity) | 73 (string-as-unibyte . identity) |
74 (string-make-unibyte . identity) | 74 (string-make-unibyte . identity) |
75 ;; string-as-multibyte often doesn't really do what you think it does. | |
76 ;; Example: | |
77 ;; (aref (string-as-multibyte "\201") 0) -> 129 (aka ?\201) | |
78 ;; (aref (string-as-multibyte "\300") 0) -> 192 (aka ?\300) | |
79 ;; (aref (string-as-multibyte "\300\201") 0) -> 192 (aka ?\300) | |
80 ;; (aref (string-as-multibyte "\300\201") 1) -> 129 (aka ?\201) | |
81 ;; but | |
82 ;; (aref (string-as-multibyte "\201\300") 0) -> 2240 | |
83 ;; (aref (string-as-multibyte "\201\300") 1) -> <error> | |
84 ;; Better use string-to-multibyte or encode-coding-string. | |
85 ;; If you really need string-as-multibyte somewhere it's usually | |
86 ;; because you're using the internal emacs-mule representation (maybe | |
87 ;; because you're using string-as-unibyte somewhere), which is | |
88 ;; generally a problem in itself. | |
89 ;; Here is an approximate equivalence table to help think about it: | |
90 ;; (string-as-multibyte s) ~= (decode-coding-string s 'emacs-mule) | |
91 ;; (string-to-multibyte s) ~= (decode-coding-string s 'binary) | |
92 ;; (string-make-multibyte s) ~= (decode-coding-string s locale-coding-system) | |
75 (string-as-multibyte . identity) | 93 (string-as-multibyte . identity) |
94 (string-to-multibyte . mm-string-as-multibyte) | |
76 (multibyte-string-p . ignore) | 95 (multibyte-string-p . ignore) |
77 ;; It is not a MIME function, but some MIME functions use it. | 96 ;; It is not a MIME function, but some MIME functions use it. |
78 (make-temp-file . (lambda (prefix &optional dir-flag) | 97 (make-temp-file . (lambda (prefix &optional dir-flag) |
79 (let ((file (expand-file-name | 98 (let ((file (expand-file-name |
80 (make-temp-name prefix) | 99 (make-temp-name prefix) |
936 ;; Fixme: This doesn't look useful where it's used. | 955 ;; Fixme: This doesn't look useful where it's used. |
937 (if (fboundp 'detect-coding-region) | 956 (if (fboundp 'detect-coding-region) |
938 (defun mm-detect-coding-region (start end) | 957 (defun mm-detect-coding-region (start end) |
939 "Like `detect-coding-region' except returning the best one." | 958 "Like `detect-coding-region' except returning the best one." |
940 (let ((coding-systems | 959 (let ((coding-systems |
941 (detect-coding-region (point) (point-max)))) | 960 (detect-coding-region start end))) |
942 (or (car-safe coding-systems) | 961 (or (car-safe coding-systems) |
943 coding-systems))) | 962 coding-systems))) |
944 (defun mm-detect-coding-region (start end) | 963 (defun mm-detect-coding-region (start end) |
945 (let ((point (point))) | 964 (let ((point (point))) |
946 (goto-char start) | 965 (goto-char start) |
960 cs))) | 979 cs))) |
961 | 980 |
962 | 981 |
963 (provide 'mm-util) | 982 (provide 'mm-util) |
964 | 983 |
965 ;;; arch-tag: 94dc5388-825d-4fd1-bfa5-2100aa351238 | 984 ;; arch-tag: 94dc5388-825d-4fd1-bfa5-2100aa351238 |
966 ;;; mm-util.el ends here | 985 ;;; mm-util.el ends here |