func (v *Varnam) Transliterate(text string) []string { var va *C.varray C.varnam_transliterate(v.handle, C.CString(text), &va) var i C.int var array []string for i = 0; i < C.varray_length(va); i++ { word := (*C.vword)(C.varray_get(va, i)) array = append(array, C.GoString(word.text)) } return array }
func (v *Varnam) Transliterate(text string) ([]string, error) { var va *C.varray rc := C.varnam_transliterate(v.handle, C.CString(text), &va) if rc != C.VARNAM_SUCCESS { errorCode := (int)(rc) return nil, &VarnamError{errorCode: errorCode, message: v.getVarnamError(errorCode)} } var i C.int var array []string for i = 0; i < C.varray_length(va); i++ { word := (*C.vword)(C.varray_get(va, i)) array = append(array, C.GoString(word.text)) } return array, nil }