mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-25 07:08:12 +08:00
raw access to string bytes
This commit is contained in:
parent
adcfe4cadb
commit
619be5b1a4
12
quickjs.c
12
quickjs.c
@ -3994,6 +3994,18 @@ JSValue JS_NewAtomString(JSContext *ctx, const char *str)
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t *JS_ToCStringLenRaw(JSContext *ctx, size_t *plen, JSValueConst val)
|
||||||
|
{
|
||||||
|
if (JS_VALUE_GET_TAG(val) != JS_TAG_STRING)
|
||||||
|
{
|
||||||
|
if(plen) *plen = 0;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
JSString *str = JS_VALUE_GET_STRING(val);
|
||||||
|
if(plen) *plen = str->len;
|
||||||
|
return str->u.str8;
|
||||||
|
}
|
||||||
|
|
||||||
/* return (NULL, 0) if exception. */
|
/* return (NULL, 0) if exception. */
|
||||||
/* return pointer into a JSString with a live ref_count */
|
/* return pointer into a JSString with a live ref_count */
|
||||||
/* cesu8 determines if non-BMP1 codepoints are encoded as 1 or 2 utf-8 sequences */
|
/* cesu8 determines if non-BMP1 codepoints are encoded as 1 or 2 utf-8 sequences */
|
||||||
|
@ -702,6 +702,7 @@ JSValue JS_NewString(JSContext *ctx, const char *str);
|
|||||||
JSValue JS_NewAtomString(JSContext *ctx, const char *str);
|
JSValue JS_NewAtomString(JSContext *ctx, const char *str);
|
||||||
JSValue JS_ToString(JSContext *ctx, JSValueConst val);
|
JSValue JS_ToString(JSContext *ctx, JSValueConst val);
|
||||||
JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val);
|
JSValue JS_ToPropertyKey(JSContext *ctx, JSValueConst val);
|
||||||
|
uint8_t *JS_ToCStringLenRaw(JSContext *ctx, size_t *plen, JSValueConst val1);
|
||||||
const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValueConst val1, JS_BOOL cesu8);
|
const char *JS_ToCStringLen2(JSContext *ctx, size_t *plen, JSValueConst val1, JS_BOOL cesu8);
|
||||||
static inline const char *JS_ToCStringLen(JSContext *ctx, size_t *plen, JSValueConst val1)
|
static inline const char *JS_ToCStringLen(JSContext *ctx, size_t *plen, JSValueConst val1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user