From d10458058daca7b53074a3d6d8a297630e2ea288 Mon Sep 17 00:00:00 2001 From: "william.xwl" Date: Mon, 31 Jul 2006 17:05:00 +0000 Subject: 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 --- emms-info-mp3info.el | 25 +++++++++++++++++++------ 1 file 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 -- cgit v1.2.3