static int32_t U_CALLCONV ucasemap_internalUTF8Fold(const UCaseMap *csm, uint8_t *dest, int32_t destCapacity, const uint8_t *src, int32_t srcLength, UErrorCode *pErrorCode) { return utf8_foldCase(csm->csp, dest, destCapacity, src, srcLength, csm->options, pErrorCode); }
static int32_t caseMap(const UCaseMap *csm, uint8_t *dest, int32_t destCapacity, const uint8_t *src, int32_t srcLength, int32_t toWhichCase, UErrorCode *pErrorCode) { int32_t destLength; /* check argument values */ if(U_FAILURE(*pErrorCode)) { return 0; } if( destCapacity<0 || (dest==NULL && destCapacity>0) || src==NULL || srcLength<-1 ) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } /* get the string length */ if(srcLength==-1) { srcLength=(int32_t)uprv_strlen((const char *)src); } /* check for overlapping source and destination */ if( dest!=NULL && ((src>=dest && src<(dest+destCapacity)) || (dest>=src && dest<(src+srcLength))) ) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } destLength=0; if(toWhichCase==FOLD_CASE) { destLength=utf8_foldCase(csm->csp, dest, destCapacity, src, srcLength, csm->options, pErrorCode); } else { UCaseContext csc={ NULL }; csc.p=(void *)src; csc.limit=srcLength; if(toWhichCase==TO_LOWER) { destLength=_caseMap(csm, ucase_toFullLower, dest, destCapacity, src, &csc, 0, srcLength, pErrorCode); } else if(toWhichCase==TO_UPPER) { destLength=_caseMap(csm, ucase_toFullUpper, dest, destCapacity, src, &csc, 0, srcLength, pErrorCode); } else /* if(toWhichCase==TO_TITLE) */ { #if UCONFIG_NO_BREAK_ITERATION *pErrorCode=U_UNSUPPORTED_ERROR; #else /* UCaseMap is actually non-const in toTitle() APIs. */ UCaseMap *tmp = (UCaseMap *)csm; destLength=_toTitle(tmp, dest, destCapacity, src, &csc, srcLength, pErrorCode); #endif } } return u_terminateChars((char *)dest, destCapacity, destLength, pErrorCode); }