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