Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
duk_hstring_misc.c File Reference
#include "duk_internal.h"

Go to the source code of this file.

Functions

DUK_INTERNAL duk_ucodepoint_t duk_hstring_char_code_at_raw (duk_hthread *thr, duk_hstring *h, duk_uint_t pos)
 

Function Documentation

◆ duk_hstring_char_code_at_raw()

DUK_INTERNAL duk_ucodepoint_t duk_hstring_char_code_at_raw ( duk_hthread * thr,
duk_hstring * h,
duk_uint_t pos )

Definition at line 7 of file duktape-1.8.0/src-separate/duk_hstring_misc.c.

7 {
8 duk_uint32_t boff;
9 const duk_uint8_t *p, *p_start, *p_end;
11
12 /* Caller must check character offset to be inside the string. */
13 DUK_ASSERT(thr != NULL);
14 DUK_ASSERT(h != NULL);
15 DUK_ASSERT_DISABLE(pos >= 0); /* unsigned */
17
18 boff = duk_heap_strcache_offset_char2byte(thr, h, (duk_uint32_t) pos);
19 DUK_DDD(DUK_DDDPRINT("charCodeAt: pos=%ld -> boff=%ld, str=%!O",
20 (long) pos, (long) boff, (duk_heaphdr *) h));
21 DUK_ASSERT_DISABLE(boff >= 0);
23
24 p_start = DUK_HSTRING_GET_DATA(h);
25 p_end = p_start + DUK_HSTRING_GET_BYTELEN(h);
26 p = p_start + boff;
27 DUK_DDD(DUK_DDDPRINT("p_start=%p, p_end=%p, p=%p",
28 (const void *) p_start, (const void *) p_end,
29 (const void *) p));
30
31 /* This may throw an error though not for valid E5 strings. */
32 cp = duk_unicode_decode_xutf8_checked(thr, &p, p_start, p_end);
33 return cp;
34}
duk_uint_fast32_t duk_uint_t
#define DUK_HSTRING_GET_DATA(x)
#define DUK_HSTRING_GET_CHARLEN(x)
#define DUK_ASSERT_DISABLE(x)
DUK_INTERNAL_DECL duk_uint_fast32_t duk_heap_strcache_offset_char2byte(duk_hthread *thr, duk_hstring *h, duk_uint_fast32_t char_offset)
#define DUK_HSTRING_GET_BYTELEN(x)
DUK_INTERNAL_DECL duk_ucodepoint_t duk_unicode_decode_xutf8_checked(duk_hthread *thr, const duk_uint8_t **ptr, const duk_uint8_t *ptr_start, const duk_uint8_t *ptr_end)
#define NULL
Definition gmacros.h:924

References DUK_ASSERT, DUK_ASSERT_DISABLE, DUK_DDD, DUK_DDDPRINT, duk_heap_strcache_offset_char2byte(), DUK_HSTRING_GET_BYTELEN, DUK_HSTRING_GET_CHARLEN, DUK_HSTRING_GET_DATA, duk_unicode_decode_xutf8_checked(), and NULL.