1467 |
by encode-coding-string, generate a new temp buffer, insert the |
by encode-coding-string, generate a new temp buffer, insert the |
1468 |
text, and convert it in the temporary buffer. Otherwise, convert in-place." |
text, and convert it in the temporary buffer. Otherwise, convert in-place." |
1469 |
(save-match-data |
(save-match-data |
1470 |
;; Setup a working buffer if necessary. |
(let ((workbuf (get-buffer-create " *code-conversion-work*"))) |
1471 |
(cond ((stringp from) |
;; Setup a working buffer if necessary. |
1472 |
(let ((buf (current-buffer))) |
(cond ((stringp from) |
1473 |
(set-buffer (generate-new-buffer " *temp")) |
(set-buffer workbuf) |
1474 |
|
(erase-buffer) |
1475 |
(set-buffer-multibyte (multibyte-string-p from)) |
(set-buffer-multibyte (multibyte-string-p from)) |
1476 |
(insert from))) |
(insert from)) |
1477 |
((not (string= (buffer-name) " *code-converting-work*")) |
((not (eq (current-buffer) workbuf)) |
1478 |
(let ((buf (current-buffer)) |
(let ((buf (current-buffer)) |
1479 |
(multibyte enable-multibyte-characters)) |
(multibyte enable-multibyte-characters)) |
1480 |
(set-buffer (generate-new-buffer " *temp")) |
(set-buffer workbuf) |
1481 |
(set-buffer-multibyte multibyte) |
(erase-buffer) |
1482 |
(insert-buffer-substring buf from to)))) |
(set-buffer-multibyte multibyte) |
1483 |
|
(insert-buffer-substring buf from to))))) |
1484 |
|
|
1485 |
;; Now we can encode the whole buffer. |
;; Now we can encode the whole buffer. |
1486 |
(let ((encoding-table (ctext-non-standard-encodings-table)) |
(let ((encoding-table (ctext-non-standard-encodings-table)) |