JavaScript-1.5 Reference

JS_InternUCStringN Function

Summary

Creates a new, static, Unicode-encoded, JS string of a specified size whose value is automatically shared by all string literals that are identical.

Syntax

JSString * JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length);

Description

JS_InternUCStringN creates a new, Unicode-encoded JS string with a specified value, s, up to length characters in size, if it does not already exist. If the number of characters in s is greater than the number of characters specified in length, the new JS string contains a truncated version of the original string. If the number of characters in s is less than the number of bytes specified in length, the new JS string is padded with nulls to the specified length.

The char array, s, must be allocated on the heap. The JS string is an interned, Unicode version of s, meaning that independent C variables that define a matching string will, when translated to a JS string value using JS_InternUCStringN, share the same internal copy of the JS string, rather than define their own, separate copies in memory. Use this function to save space allocation on the heap.

If it creates or reuses an interned string, JS_InternUCStringN returns a pointer to the string. Otherwise, on error, it returns NULL.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JS_CompareStrings | JS_ConvertValue | JS_GetEmptyStringValue | JS_GetStringBytes | JS_GetStringChars | JS_GetStringLength | JS_InternString | JS_InternUCString | JS_NewArrayObject | JS_NewDouble | JS_NewFunction | JS_NewObject | JS_NewString | JS_NewStringCopyN | JS_NewStringCopyZ | JS_NewUCString | JS_NewUCStringCopyN | JS_NewUCStringCopyZ | JS_ValueToString ]

This page was generated by APIDOC