static UINTVAL ucs4_ord(PARROT_INTERP, ARGIN(const STRING *src), INTVAL idx) { ASSERT_ARGS(ucs4_ord) const utf32_t * const ptr = (utf32_t *)src->strstart; const UINTVAL len = src->strlen; if (idx < 0) idx += len; if ((UINTVAL)idx >= len) encoding_ord_error(interp, src, idx); return ptr[idx]; }
static UINTVAL utf8_ord(PARROT_INTERP, ARGIN(const STRING *src), INTVAL idx) { ASSERT_ARGS(utf8_ord) const UINTVAL len = STRING_length(src); const utf8_t *start; if (idx < 0) idx += len; if ((UINTVAL)idx >= len) encoding_ord_error(interp, src, idx); start = utf8_skip_forward((utf8_t *)src->strstart, idx); return utf8_decode(interp, start); }