Created
August 28, 2013 07:12
-
-
Save ekd123/6362987 to your computer and use it in GitHub Desktop.
Revisions
-
ekd123 created this gist
Aug 28, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,39 @@ #!/usr/bin/env tclsh package require Tk pack [ttk::label .l1 -text "在下面的框中輸入要檢查的文本"] -fill x pack [text .input] -fill both -expand 1 pack [ttk::label .l2 -text "結果"] -fill x pack [text .output] -fill both -expand 1 pack [ttk::button .start -text "開始" -command startFind] -side right proc charIsChinese {ch} { set code [scan $ch %c] if { $code > 0x3400 && $code < 0x4DB5 } { return true } elseif { $code > 0x4E00 && $code < 0x9FA5 } { return true } elseif { $code > 0x9FA6 && $code < 0x9FBB } { return true } elseif { $code > 0xF900 && $code < 0xFA2D } { return true } elseif { $code > 0xFA30 && $code < 0xFA6A } { return true } elseif { $code > 0xFA70 && $code < 0xFAD9 } { return true } elseif { $code > 0x20000 && $code < 0x2A6D6 } { return true } elseif { $code > 0x2F800 && $code < 0x2FA1D } { return true } else { return false } } proc startFind {} { foreach ch [split [.input get 1.0 {end -1c}] {}] { if { [charIsChinese $ch] } { .output insert end $ch } } }