Skip to content

Instantly share code, notes, and snippets.

@syou6162
Created February 21, 2012 11:56
Show Gist options
  • Save syou6162/1876100 to your computer and use it in GitHub Desktop.
Save syou6162/1876100 to your computer and use it in GitHub Desktop.
ClojureでJavaのUnicodeBlockを使って文字種を判定する方法について
;; see also http://java.sun.com/j2se/1.5.0/ja/docs/ja/api/java/lang/Character.UnicodeBlock.html
(import 'java.lang.Character$UnicodeBlock)
;; java.lang.Character$UnicodeBlock
(Character$UnicodeBlock/of \u3042)
;; #<UnicodeBlock HIRAGANA>
(map #(Character$UnicodeBlock/of %) "日本だ")
;; (#<UnicodeBlock CJK_UNIFIED_IDEOGRAPHS> #<UnicodeBlock CJK_UNIFIED_IDEOGRAPHS> #<UnicodeBlock HIRAGANA>)
(map #(= (Character$UnicodeBlock/of %) Character$UnicodeBlock/HIRAGANA) "日本だ")
;; (false false true)
(map #(Character$UnicodeBlock/of %) "ブログ")
;; (#<UnicodeBlock KATAKANA> #<UnicodeBlock KATAKANA> #<UnicodeBlock KATAKANA>)
;; Character$UnicodeBlock/KATAKANA
(map #(Character$UnicodeBlock/of %) "Japan")
;; (#<UnicodeBlock BASIC_LATIN> #<UnicodeBlock BASIC_LATIN> #<UnicodeBlock BASIC_LATIN> #<UnicodeBlock BASIC_LATIN> #<UnicodeBlock BASIC_LATIN>)
;; Character$UnicodeBlock/BASIC_LATIN
(map #(Character$UnicodeBlock/of %) ",.!?")
;; (#<UnicodeBlock BASIC_LATIN> #<UnicodeBlock BASIC_LATIN> #<UnicodeBlock BASIC_LATIN> #<UnicodeBlock BASIC_LATIN>)
;; むむ、これはちょっと問題か。。。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment