aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwilliam.xwl <william.xwl>2006-07-31 17:05:00 +0000
committerwilliam.xwl <mwolson@gnu.org>2006-07-31 17:05:00 +0000
commitd10458058daca7b53074a3d6d8a297630e2ea288 (patch)
treeaa94954ba5b26e13217f09e9bcab6cd2f32169a5
parent43c306146f67f59f89d262e9b91c3d21bd6910a1 (diff)
emms-info-mp3info.el: New function, emms-iconv, for converting string
between different coding systems. The conversion is necessary when emms-info-mp3info-coding-system is different from emms-cache-file-coding-system. darcs-hash:20060731170503-e8fe6-0db1b71cfdc7dc39687c9b5297351541e436e8bf.gz
-rw-r--r--emms-info-mp3info.el25
1 files changed, 19 insertions, 6 deletions
diff --git a/emms-info-mp3info.el b/emms-info-mp3info.el
index 61ad8f1..46d15a0 100644
--- a/emms-info-mp3info.el
+++ b/emms-info-mp3info.el
@@ -79,16 +79,20 @@ This is a useful element for `emms-info-functions'."
(string-match "\\.[Mm][Pp]3\\'" (emms-track-name track)))
(with-temp-buffer
(when (zerop
- (let ((coding-system-for-read emms-info-mp3info-coding-system))
- (apply 'call-process
- emms-info-mp3info-program-name
- nil t nil
- (emms-track-name track)
- emms-info-mp3find-arguments)))
+ (apply 'call-process
+ emms-info-mp3info-program-name
+ nil t nil
+ (emms-track-name track)
+ emms-info-mp3find-arguments))
(goto-char (point-min))
(while (looking-at "^\\([^=\n]+\\)=\\(.*\\)$")
(let ((name (intern (match-string 1)))
(value (match-string 2)))
+ (unless (eq emms-info-mp3info-coding-system
+ emms-cache-file-coding-system)
+ (setq value (emms-iconv value
+ emms-info-mp3info-coding-system
+ emms-cache-file-coding-system)))
(when (> (length value)
0)
(emms-track-set track
@@ -98,5 +102,14 @@ This is a useful element for `emms-info-functions'."
value))))
(forward-line 1))))))
+(defun emms-iconv (str from to)
+ "Convert STR from FROM coding to TO coding."
+ (and (symbolp from) (setq from (symbol-name from)))
+ (and (symbolp to) (setq to (symbol-name to)))
+ (car
+ (split-string
+ (shell-command-to-string
+ (concat "echo \"" str "\" | iconv -f " from " -t " to)))))
+
(provide 'emms-info-mp3info)
;;; emms-info-mp3info.el ends here