One tiny suggestion s[:i] https://play.golang.org/p/_T_hqBg6ka
Thanks:-) On Monday, February 27, 2017 at 6:36:06 PM UTC, peterGo wrote: > > Mark, > > Fixed typos and made minor improvements. > > Go Playground: https://play.golang.org/p/cbQL8-72s5 > > Peter > > On Monday, February 27, 2017 at 11:05:32 AM UTC-5, Mark wrote: >> >> Ooops just realised that I didn't enforce the max chars limit. Here's >> another version: >> >> func CwcharToString(p uintptr, maxchars int) string { >> if p == 0 { >> return "" >> } >> uints := make([]uint16, 0, maxchars) >> for i, p := 0, uintptr(unsafe.Pointer(p)); i < maxchars; p += 2 { >> u := *(*uint16)(unsafe.Pointer(p)) >> if u == 0 { >> break >> } >> uints = append(uints, u) >> i++ >> } >> return string(utf16.Decode(uints)) >> } >> >> -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.