JS_GetStringChars 编辑
Obsolete since JSAPI 33
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Retrieve a pointer to the 16-bit values that make up a given string.
Syntax
jschar *
JS_GetStringChars(JSString *str); // Obsolete since JSAPI 1.8.5
const jschar *
JS_GetStringCharsZ(JSContext *cx, JSString *str); // Added in SpiderMonkey 1.8.2, Obsolete since JSAPI 33
Name | Type | Description |
---|---|---|
cx | JSContext * | (in JS_GetStringCharsZ only) A context. |
str | JSString * | The string to obtain characters from. |
Description
JS_GetStringChars
Obsolete since JavaScript 1.8.5 returns a pointer to the first element of an array of jschar
s. Warnings:
- The array is not necessarily null-terminated. To get the length of the string, use
JS_GetStringLength
. - The program must not modify the array. If it does, the behavior is undefined.
- The content of a JS string is not guaranteed to be valid UTF-16. It may contain surrogate code units that aren't properly paired. It may also contain zeroes.
The array returned by this function remains valid as long as str
is valid. (Eventually, str
becomes unreachable, the garbage collector collects it, and the array is freed by the system.)
JS_GetStringCharsZ
is the same except that it always returns either a null-terminated string or NULL
, indicating out-of-memory.
See Also
- bug 609440 - removed
JS_GetStringChars
- bug 1037869 - removed
JS_GetStringCharsZ
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论