Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE int32_t U_EXPORT2 u_strToTitle ( UChar *  dest,
int32_t  destCapacity,
const UChar *  src,
int32_t  srcLength,
UBreakIterator titleIter,
const char *  locale,
UErrorCode pErrorCode 

Titlecase a string. Casing is locale-dependent and context-sensitive. Titlecasing uses a break iterator to find the first characters of words that are to be titlecased. It titlecases those characters and lowercases all others.

The titlecase break iterator can be provided to customize for arbitrary styles, using rules and dictionaries beyond the standard iterators. It may be more efficient to always provide an iterator to avoid opening and closing one for each string. The standard titlecase iterator for the root locale implements the algorithm of Unicode TR 21.

This function uses only the setText(), first() and next() methods of the provided break iterator.

The result may be longer or shorter than the original. The source string and the destination buffer are allowed to overlap.

dest A buffer for the result string. The result will be zero-terminated if the buffer is large enough.
destCapacity The size of the buffer (number of UChars). If it is 0, then dest may be NULL and the function will only return the length of the result without writing any of the result string.
src The original string
srcLength The length of the original string. If -1, then src must be zero-terminated.
titleIter A break iterator to find the first characters of words that are to be titlecased. If none is provided (NULL), then a standard titlecase break iterator is opened.
locale The locale to consider, or "" for the root locale or NULL for the default locale.
pErrorCode Must be a valid pointer to an error code value, which must not indicate a failure before the function call.
The length of the result string. It may be greater than destCapacity. In that case, only some of the result was written to the destination buffer. ICU 2.1

Definition at line 586 of file ustrcase.c.

References UCaseMap::iter, and NULL.

    UCaseMap csm={ NULL };
    int32_t length;

    setTempCaseMap(&csm, locale, pErrorCode);
                   dest, destCapacity,
                   src, srcLength,
                   TO_TITLE, pErrorCode);
    if(titleIter==NULL && csm.iter!=NULL) {
    return length;

Generated by  Doxygen 1.6.0   Back to index