1package ieproxy 2 3import ( 4 "unicode/utf16" 5 "unsafe" 6) 7 8// StringFromUTF16Ptr converts a *uint16 C string to a Go String 9func StringFromUTF16Ptr(s *uint16) string { 10 if s == nil { 11 return "" 12 } 13 14 p := (*[1<<30 - 1]uint16)(unsafe.Pointer(s)) 15 16 // find the string length 17 sz := 0 18 for p[sz] != 0 { 19 sz++ 20 } 21 22 return string(utf16.Decode(p[:sz:sz])) 23} 24