1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 2008-2011, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
11 // This file contains utility code for supporting UText in the regular expression engine.
14 #include "unicode/utf.h"
19 U_CFUNC UChar U_CALLCONV
20 uregex_utext_unescape_charAt(int32_t offset
, void *ct
) {
21 struct URegexUTextUnescapeCharContext
*context
= (struct URegexUTextUnescapeCharContext
*)ct
;
23 if (offset
== context
->lastOffset
+ 1) {
24 c
= UTEXT_NEXT32(context
->text
);
25 context
->lastOffset
++;
26 } else if (offset
== context
->lastOffset
) {
27 c
= UTEXT_PREVIOUS32(context
->text
);
28 UTEXT_NEXT32(context
->text
);
30 utext_moveIndex32(context
->text
, offset
- context
->lastOffset
- 1);
31 c
= UTEXT_NEXT32(context
->text
);
32 context
->lastOffset
= offset
;
35 // !!!: Doesn't handle characters outside BMP
43 U_CFUNC UChar U_CALLCONV
44 uregex_ucstr_unescape_charAt(int32_t offset
, void *context
) {
45 return ((UChar
*)context
)[offset
];