From 5b5b918445b61985b0b0fe53dcafdd0b43ad24d1 Mon Sep 17 00:00:00 2001 From: raylu Date: Wed, 20 Apr 2011 01:37:00 -0400 Subject: [PATCH] Handle ideographic spaces (U+3000) in !tr --- cmd-google.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd-google.go b/cmd-google.go index 17c04e2..ae27eab 100644 --- a/cmd-google.go +++ b/cmd-google.go @@ -22,10 +22,20 @@ const googleAPIKey = "ABQIAAAA6-N_jl4ETgtMf2M52JJ_WRQjQjNunkAJHIhTdFoxe8Di7fkkYh func translate(conn *irc.Conn, nick *irc.Nick, args, target string) { var langPairs vector.StringVector for { - split := strings.Split(args, " ", 2) - if len(split) == 2 && len(split[0]) == 5 && split[0][2] == '|' { - langPairs.Push("&langpair=" + split[0]) - args = split[1] + field := strings.IndexAny(args, "  ") // handle spaces and ideographic spaces (U+3000) + if field != -1 { + first := args[:field] + if len(first) == 5 && first[2] == '|' { + langPairs.Push("&langpair=" + first) + if args[field] == ' ' { + args = args[field+1:] + } else { + args = args[field+utf8.RuneLen(3000):] + } + fmt.Printf("'%s' '%s'\n", first, args) + } else { + break + } } else { break }