hangrep.go (425B)
1 // From standard input, filter out single chinese characters to standard output. 2 3 package main 4 5 import ( 6 "bufio" 7 "fmt" 8 "os" 9 "unicode" 10 ) 11 12 func main() { 13 scanner := bufio.NewScanner(os.Stdin) 14 for scanner.Scan() { 15 text := scanner.Text() 16 runes := []rune(text) 17 if len(runes) != 1 { 18 continue 19 } 20 if isHanzi(runes[0]) { 21 fmt.Println(text) 22 } 23 } 24 } 25 26 func isHanzi(r rune) bool { 27 return unicode.Is(unicode.Han, r) 28 }