Skip to content

Commit

Permalink
add back string conversion functions. (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
fardream authored Aug 2, 2024
1 parent 66a2e6a commit 587382c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions strconvfuncs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package gmsk

// #include <mosek.h>
import "C"

import "unsafe"

// MSKWchar is the char type of mosek's wide chars, or MSKwchart
type MSKWchar C.MSKwchart

// Utf8towchar is wrapping [MSK_utf8towchar]
//
// [MSK_utf8towchar]: https://docs.mosek.com/latest/capi/alphabetic-functionalities.html#mosek.env.utf8towchar
func Utf8towchar(
outputlen uint64,
len []uint64,
conv []uint64,
output []MSKWchar,
input string,
) error {
c_input := C.CString(input)
defer C.free(unsafe.Pointer(c_input))

return ResCode(
C.MSK_utf8towchar(
C.size_t(outputlen),
(*C.size_t)(getPtrToFirst(len)),
(*C.size_t)(getPtrToFirst(conv)),
(*C.MSKwchart)(getPtrToFirst(output)),
c_input,
),
).ToError()
}

// Wchartoutf8 is wrapping [MSK_wchartoutf8]
//
// [MSK_wchartoutf8]: https://docs.mosek.com/latest/capi/alphabetic-functionalities.html#mosek.env.wchartoutf8
func Wchartoutf8(
outputlen uint64,
len []uint64,
conv []uint64,
output *byte,
input []MSKWchar,
) error {
return ResCode(
C.MSK_wchartoutf8(
C.size_t(outputlen),
(*C.size_t)(getPtrToFirst(len)),
(*C.size_t)(getPtrToFirst(conv)),
(*C.char)(unsafe.Pointer(output)),
(*C.MSKwchart)(getPtrToFirst(input)),
),
).ToError()
}

0 comments on commit 587382c

Please sign in to comment.