Skip to content

Instantly share code, notes, and snippets.

@miyamuko
Created August 19, 2010 06:03
Show Gist options
  • Select an option

  • Save miyamuko/537169 to your computer and use it in GitHub Desktop.

Select an option

Save miyamuko/537169 to your computer and use it in GitHub Desktop.
クリップボードエンコーディングを自動判別 #xyzzy
;; クリップボードエンコーディングを自動判別 #xyzzy
;; get-clipboard-data を上書きしているのでちょっとキケン
(defvar *get-clipboard-data* #'get-clipboard-data)
(defun get-clipboard-data ()
(let ((*clipboard-char-encoding* *encoding-sjis*))
(declare (special *clipboard-char-encoding*))
(let* ((str (funcall *get-clipboard-data*))
(enc (detect-char-encoding str)))
(message "Clipboard encoding: ~A: ~A" (if enc
(char-encoding-display-name enc)
"Unknown")
str)
(if (and enc str)
(identity (substitute-string
(convert-encoding-to-internal enc str)
"\r" ""))
str))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment