JS_CStringsAreUTF8 编辑
Obsolete since JSAPI 19
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.
These functions have been removed in SpiderMonkey 19. API users should switch to functions which take UTF-8 explicitly or handle their own string encoding and decoding.
Option to have the JSAPI treat char
strings as UTF-8.
Syntax
JSBool
JS_CStringsAreUTF8(void);
void
JS_SetCStringsAreUTF8(void); // Added in SpiderMonkey 1.8
Description
By default, all C/C++ strings passed into the JSAPI are treated as ISO/IEC 8859-1, also known as ISO-Latin-1. That is, each byte is treated as a Unicode character, and there is no way to pass in a string containing characters beyond U+00FF.
However, SpiderMonkey can optionally interpret these strings as UTF-8. There are two ways to enable this: at compile time, by building SpiderMonkey with JS_C_STRINGS_ARE_UTF8
defined; or at run time, by calling JS_SetCStringsAreUTF8
before the first call to JS_NewRuntime
. Enabling this option also causes JS_GetStringBytes
and JS_EncodeCharacters
to produce UTF-8 strings instead of Latin-1.
JS_CStringsAreUTF8
returns JS_TRUE
if the JavaScript engine is configured (either at compile time or at run time) to interpret char
strings as UTF-8.
See Also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论