From 8d6747933abdeb5c60d58e1c53cf21b9b3f7814d Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Sun, 29 Sep 2013 14:52:43 -0700 Subject: [PATCH] add print-code-points.go Signed-off-by: Colin McCabe --- .gitignore | 1 + print-code-points.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 0 deletions(-) create mode 100644 print-code-points.go 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) +} -- 1.6.6.rc1.39.g9a42