72 |
string))) |
string))) |
73 |
(string-as-unibyte . identity) |
(string-as-unibyte . identity) |
74 |
(string-make-unibyte . identity) |
(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) |
93 |
(string-as-multibyte . identity) |
(string-as-multibyte . identity) |
94 |
|
(string-to-multibyte . mm-string-as-multibyte) |
95 |
(multibyte-string-p . ignore) |
(multibyte-string-p . ignore) |
96 |
;; It is not a MIME function, but some MIME functions use it. |
;; It is not a MIME function, but some MIME functions use it. |
97 |
(make-temp-file . (lambda (prefix &optional dir-flag) |
(make-temp-file . (lambda (prefix &optional dir-flag) |
957 |
(defun mm-detect-coding-region (start end) |
(defun mm-detect-coding-region (start end) |
958 |
"Like `detect-coding-region' except returning the best one." |
"Like `detect-coding-region' except returning the best one." |
959 |
(let ((coding-systems |
(let ((coding-systems |
960 |
(detect-coding-region (point) (point-max)))) |
(detect-coding-region start end))) |
961 |
(or (car-safe coding-systems) |
(or (car-safe coding-systems) |
962 |
coding-systems))) |
coding-systems))) |
963 |
(defun mm-detect-coding-region (start end) |
(defun mm-detect-coding-region (start end) |
981 |
|
|
982 |
(provide 'mm-util) |
(provide 'mm-util) |
983 |
|
|
984 |
;;; arch-tag: 94dc5388-825d-4fd1-bfa5-2100aa351238 |
;; arch-tag: 94dc5388-825d-4fd1-bfa5-2100aa351238 |
985 |
;;; mm-util.el ends here |
;;; mm-util.el ends here |