mirror of
https://github.com/rclone/rclone.git
synced 2024-12-05 07:20:35 +08:00
24 lines
350 B
Go
24 lines
350 B
Go
package ieproxy
|
|
|
|
import (
|
|
"unicode/utf16"
|
|
"unsafe"
|
|
)
|
|
|
|
// StringFromUTF16Ptr converts a *uint16 C string to a Go String
|
|
func StringFromUTF16Ptr(s *uint16) string {
|
|
if s == nil {
|
|
return ""
|
|
}
|
|
|
|
p := (*[1<<30 - 1]uint16)(unsafe.Pointer(s))
|
|
|
|
// find the string length
|
|
sz := 0
|
|
for p[sz] != 0 {
|
|
sz++
|
|
}
|
|
|
|
return string(utf16.Decode(p[:sz:sz]))
|
|
}
|