diff options
Diffstat (limited to 'libgo/go/strconv/makeisprint.go')
-rw-r--r-- | libgo/go/strconv/makeisprint.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libgo/go/strconv/makeisprint.go b/libgo/go/strconv/makeisprint.go index 588d0a0..5142580 100644 --- a/libgo/go/strconv/makeisprint.go +++ b/libgo/go/strconv/makeisprint.go @@ -174,6 +174,23 @@ func main() { } fmt.Fprintf(&buf, "\t%#04x,\n", r-0x10000) } + fmt.Fprintf(&buf, "}\n\n") + + // The list of graphic but not "printable" runes is short. Just make one easy table. + fmt.Fprintf(&buf, "// isGraphic lists the graphic runes not matched by IsPrint.\n") + fmt.Fprintf(&buf, "var isGraphic = []uint16{\n") + for r := rune(0); r <= unicode.MaxRune; r++ { + if unicode.IsPrint(r) != unicode.IsGraphic(r) { + // Sanity check. + if !unicode.IsGraphic(r) { + log.Fatalf("%U is printable but not graphic\n", r) + } + if r > 0xFFFF { // We expect only 16-bit values. + log.Fatalf("%U too big for isGraphic\n", r) + } + fmt.Fprintf(&buf, "\t%#04x,\n", r) + } + } fmt.Fprintf(&buf, "}\n") data, err := format.Source(buf.Bytes()) |