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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:133 次

字数:2959

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文