2 *******************************************************************************
3 * Copyright (C) 2011, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 * file name: ucasemap_titlecase_brkiter.cpp
8 * tab size: 8 (not used)
11 * created on: 2011jun02
12 * created by: Markus W. Scherer
14 * Titlecasing functions that are based on BreakIterator
15 * were moved here to break dependency cycles among parts of the common library.
18 #include "unicode/utypes.h"
20 #if !UCONFIG_NO_BREAK_ITERATION
22 #include "unicode/brkiter.h"
23 #include "unicode/ubrk.h"
24 #include "unicode/ucasemap.h"
31 U_CAPI
const UBreakIterator
* U_EXPORT2
32 ucasemap_getBreakIterator(const UCaseMap
*csm
) {
37 ucasemap_setBreakIterator(UCaseMap
*csm
, UBreakIterator
*iterToAdopt
, UErrorCode
* /*pErrorCode*/) {
38 // Do not call ubrk_close() so that we do not depend on all of the BreakIterator code.
39 delete reinterpret_cast<BreakIterator
*>(csm
->iter
);
40 csm
->iter
=iterToAdopt
;
43 U_CAPI
int32_t U_EXPORT2
44 ucasemap_utf8ToTitle(UCaseMap
*csm
,
45 char *dest
, int32_t destCapacity
,
46 const char *src
, int32_t srcLength
,
47 UErrorCode
*pErrorCode
) {
48 UText utext
=UTEXT_INITIALIZER
;
49 utext_openUTF8(&utext
, (const char *)src
, srcLength
, pErrorCode
);
50 if(U_FAILURE(*pErrorCode
)) {
54 csm
->iter
=ubrk_open(UBRK_WORD
, csm
->locale
,
58 ubrk_setUText(csm
->iter
, &utext
, pErrorCode
);
59 int32_t length
=ucasemap_mapUTF8(csm
,
60 (uint8_t *)dest
, destCapacity
,
61 (const uint8_t *)src
, srcLength
,
62 ucasemap_internalUTF8ToTitle
, pErrorCode
);
67 #endif // !UCONFIG_NO_BREAK_ITERATION