2013/06/22

Re: Unicodeで遊ぶ

Unicodeには、Ⓐ、ⓐなどといったマル付きの英文字があるみたいなので、英文字列を入力するとマル付き文字に変換する簡単なスクリプトを作ってみました。
というのを見かけたので、試しにGaucheで。
(use srfi-13)
(use srfi-14)
(define (ab->maru str)
(string-map
(^c (let1 i (char->integer c)
(integer->char
(cond ((char-set-contains? #[a-z] c)
(+ (- i (char->integer #\a)) #x24d0))
((char-set-contains? #[A-Z] c)
(+ (- i (char->integer #\A)) #x24b6))
(else i)))))
str))
(print (ab->maru "Masahide Maehara"))
;; => Ⓜⓐⓢⓐⓗⓘⓓⓔ Ⓜⓐⓔⓗⓐⓡⓐ
view raw ab2maru.scm hosted with ❤ by GitHub

0 件のコメント:

コメントを投稿