func DCEncode(s string) string { cs := C.CString(s) defer C.free(unsafe.Pointer(cs)) buf := C.malloc(255) defer C.free(buf) n := C.dc_encode((*_Ctype_char)(buf), cs, (_Ctype_int)(len(s))) if n > 0 { return C.GoStringN((*_Ctype_char)(buf), n) } return s }
func (dc *Codec) Encode(src string) (dst string, idx int) { var cdc *C.Codec = dc.cdc n := C.dc_encode(cdc, dc.buf, BUFSIZE, C.CString(src), C.int(len(src))) return C.GoStringN(dc.buf, n), 1 }