MCPcopy Create free account
hub / github.com/buke/quickjs-go / NewStringUTF16

Method NewStringUTF16

context.go:403–415  ·  view source on GitHub ↗

NewStringUTF16 returns a string value from UTF-16 code units.

(v []uint16)

Source from the content-addressed store, hash-verified

401
402// NewStringUTF16 returns a string value from UTF-16 code units.
403func (ctx *Context) NewStringUTF16(v []uint16) *Value {
404 if !ctx.hasValidRef() {
405 return nil
406 }
407
408 var ptr *C.uint16_t
409 if len(v) > 0 {
410 ptr = (*C.uint16_t)(unsafe.Pointer(&v[0]))
411 }
412 ref := C.JS_NewStringUTF16(ctx.ref, ptr, C.size_t(len(v)))
413 goruntime.KeepAlive(v)
414 return &Value{ctx: ctx, ref: ref}
415}
416
417// NewDate returns a JavaScript Date object from epoch milliseconds.
418func (ctx *Context) NewDate(epochMS float64) *Value {

Callers 2

Calls 1

hasValidRefMethod · 0.95

Tested by 2