[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tue, 19 Jul 2005 12:49:36 +0900 (JST)
>>>>> On Tue, 19 Jul 2005 11:56:37 +0900, Kenichi Handa <address@hidden> said:
> If a multibyte string is given to mac-code-convert-string, and the
> string is made mutlibyte by string-to-multibyte from the raw-byte
> sequence (ex. inserting a file by raw-text in a mutlibyte buffer and
> extracting a string by buffer-substring), using Fstring_as_unibyte
> is correct.
That's the case for mac-code-convert-string. Thanks for clarifying.
As for the `mac-hfs+' coding system shown in my previous mail, its
coding-system-type should have been 5 (raw-text), rather than 0
(emacs-mule) so that the leading bytes for eight-bit-control and
eight-bit-graphic may not be eaten. And I had to do
(set-buffer-multibyte t) explicitly for the case of
decode-coding-string. Maybe " *code-converting-work*" in
ctext-post-read-conversion should be " *code-conversion-work*" ?
"Like utf-8, but additionally does Mac HFS+ composition on decoding."
(list (cons 'safe-charsets (coding-system-get 'utf-8 'safe-charsets))
'(post-read-conversion . mac-hfs+-post-read-conversion)
'(pre-write-conversion . mac-hfs+-pre-write-conversion)))
(defun mac-hfs+-post-read-conversion (length)
(narrow-to-region (point) (+ (point) length))
(let ((in-workbuf (string= (buffer-name) " *code-conversion-work*"))
(str (mac-code-convert-string (buffer-string)
'utf-8 'utf-8 'HFS+C)))
(insert (if enable-multibyte-characters
(string-to-multibyte str) str)))
(setq length (decode-coding-region (point-min) (point-max) 'utf-8))
;; We are inside a post-read-conversion function, so the
;; original post-read-conversion for utf-8 is not
;; automatically called.
(funcall (or (coding-system-get 'utf-8 'post-read-conversion)
(defun mac-hfs+-pre-write-conversion (beg end)
(funcall (or (coding-system-get 'utf-8 'pre-write-conversion) 'ignore)
beg (+ beg (encode-coding-region beg end 'utf-8))))
(setq default-file-name-coding-system 'mac-hfs+)