func frame(data string, json bool) string { utf8str := utf8.NewString(data) if json { return fmt.Sprintf("~m~%d~m~~j~%s", 3+utf8str.RuneCount(), data) } return fmt.Sprintf("~m~%d~m~%s", utf8str.RuneCount(), data) }
func streamingFrame(data string, typ int, json bool) string { utf8str := utf8.NewString(data) switch typ { case 0: return "0:0:," case 2, 3: return fmt.Sprintf("%d:%d:%s,", typ, utf8str.RuneCount(), data) } if json { return fmt.Sprintf("%d:%d:j\n:%s,", typ, 3+utf8str.RuneCount(), data) } return fmt.Sprintf("%d:%d::%s,", typ, 1+utf8str.RuneCount(), data) }
func isPrivate(n string) bool { dst := utf8.NewString(n) return unicode.IsLower(dst.At(0)) }