MCPcopy Create free account
hub / github.com/dop251/goja / AsUtf16

Method AsUtf16

unistring/string.go:110–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

108}
109
110func (s String) AsUtf16() []uint16 {
111 if len(s) < 4 || len(s)&1 != 0 {
112 return nil
113 }
114
115 a := unsafe.Slice((*uint16)(unsafe.Pointer(unsafe.StringData(string(s)))), len(s)/2)
116
117 if a[0] == BOM {
118 return a
119 }
120
121 return nil
122}

Callers 4

StringMethod · 0.95
unicodeStringFromRunesFunction · 0.80
stringValueFromRawFunction · 0.80
TestString_AsUtf16Function · 0.80

Implementers 1

importedStringstring_imported.go

Calls

no outgoing calls

Tested by 1

TestString_AsUtf16Function · 0.64