Y.A.S.D.

« QR | Main | メモ »

実体参照

(require 'un-define)
(require 'utf)
(defun TT:html-entitize (&optional b e)
  (interactive)
  (unless (and b e)
    (setq b (region-beginning)
	  e (region-end)))
  (let ((str "") (cl))
    (setq cl (cddr (string-to-list 
		    (mucs-convert-string (buffer-substring b e)
					 'utf-16-be-unix-stream-encoder
					 t))))
    (while cl
      (setq str (concat str (format "&#%d;"
				    (+ (* 256 (car cl)) (cadr cl))))
	    cl (cddr cl)))
    (goto-char b)
    (delete-region b e)
    (insert str)))
( ・∀・)つ〃∩ ヘェー
↓
( ・∀・)つ〃∩ ヘェー

츠무라토모아키
↓
츠무라토모아키

なんかゴテゴテしてるかも...。 実体参照にしなくていい文字まで問答無用で変換してる。 spamよけとかにも使えるし(謎)。もっと楽な方法はないか。

 

Comments:

Post a Comment:
  • HTML Syntax: Allowed

[Masubi]
Copyright © 1998-2009 Tomoaki TSUMURA. Powered by Apache Roller 4.0.1.
tomoaki@tsumura.info