diff options
Diffstat (limited to 'src/couchdb/priv/couch_js/utf8.c')
-rw-r--r-- | src/couchdb/priv/couch_js/utf8.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/couchdb/priv/couch_js/utf8.c b/src/couchdb/priv/couch_js/utf8.c index 699a6fee..d6064267 100644 --- a/src/couchdb/priv/couch_js/utf8.c +++ b/src/couchdb/priv/couch_js/utf8.c @@ -11,6 +11,7 @@ // the License. #include <jsapi.h> +#include "config.h" static int enc_char(uint8 *utf8Buffer, uint32 ucs4Char) @@ -121,7 +122,7 @@ char* enc_string(JSContext* cx, jsval arg, size_t* buflen) { JSString* str = NULL; - jschar* src = NULL; + const jschar* src = NULL; char* bytes = NULL; size_t srclen = 0; size_t byteslen = 0; @@ -129,8 +130,12 @@ enc_string(JSContext* cx, jsval arg, size_t* buflen) str = JS_ValueToString(cx, arg); if(!str) goto error; +#ifdef HAVE_JS_GET_STRING_CHARS_AND_LENGTH + src = JS_GetStringCharsAndLength(cx, str, &srclen); +#else src = JS_GetStringChars(str); srclen = JS_GetStringLength(str); +#endif if(!enc_charbuf(src, srclen, NULL, &byteslen)) goto error; @@ -283,4 +288,4 @@ error: success: return str; -}
\ No newline at end of file +} |