From: Colin Patrick Mccabe Date: Sun, 29 Sep 2013 21:52:43 +0000 (-0700) Subject: add print-code-points.go X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d6747933abdeb5c60d58e1c53cf21b9b3f7814d;p=cmccabe-bin add print-code-points.go Signed-off-by: Colin McCabe --- diff --git a/.gitignore b/.gitignore index 65c02f9..6c30d1d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ errno_speak simple_time vimstart show_default_sockopts +print-code-points # # Normal rules diff --git a/print-code-points.go b/print-code-points.go new file mode 100644 index 0000000..1745402 --- /dev/null +++ b/print-code-points.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "os" +) + +func usage(retval int) { + fmt.Printf("print-code-points: prints out the code points in a unicode string.\n" + + "\n" + + "usage: print-code-points \n") + os.Exit(retval) +} + +func main() { + if (len(os.Args) != 2) { + usage(1) + } + str := os.Args[1] + for pos, codePoint := range str { + fmt.Printf("Code Point 0x%04x: '%s'\n", codePoint, str[pos:pos+1]) + } + os.Exit(0) +}