1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/regextxt.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,46 @@ 1.4 +/******************************************************************** 1.5 + * COPYRIGHT: 1.6 + * Copyright (c) 2008-2011, International Business Machines Corporation and 1.7 + * others. All Rights Reserved. 1.8 + ********************************************************************/ 1.9 +// 1.10 +// file: regextxt.cpp 1.11 +// 1.12 +// This file contains utility code for supporting UText in the regular expression engine. 1.13 +// 1.14 + 1.15 +#include "unicode/utf.h" 1.16 +#include "regextxt.h" 1.17 + 1.18 +U_NAMESPACE_BEGIN 1.19 + 1.20 +U_CFUNC UChar U_CALLCONV 1.21 +uregex_utext_unescape_charAt(int32_t offset, void *ct) { 1.22 + struct URegexUTextUnescapeCharContext *context = (struct URegexUTextUnescapeCharContext *)ct; 1.23 + UChar32 c; 1.24 + if (offset == context->lastOffset + 1) { 1.25 + c = UTEXT_NEXT32(context->text); 1.26 + context->lastOffset++; 1.27 + } else if (offset == context->lastOffset) { 1.28 + c = UTEXT_PREVIOUS32(context->text); 1.29 + UTEXT_NEXT32(context->text); 1.30 + } else { 1.31 + utext_moveIndex32(context->text, offset - context->lastOffset - 1); 1.32 + c = UTEXT_NEXT32(context->text); 1.33 + context->lastOffset = offset; 1.34 + } 1.35 + 1.36 + // !!!: Doesn't handle characters outside BMP 1.37 + if (U_IS_BMP(c)) { 1.38 + return (UChar)c; 1.39 + } else { 1.40 + return 0; 1.41 + } 1.42 +} 1.43 + 1.44 +U_CFUNC UChar U_CALLCONV 1.45 +uregex_ucstr_unescape_charAt(int32_t offset, void *context) { 1.46 + return ((UChar *)context)[offset]; 1.47 +} 1.48 + 1.49 +U_NAMESPACE_END