1b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 2b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************** 350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho* Copyright (C) 1999-2010, International Business Machines 4b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 5b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru********************************************************************** 6b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* file name: ustr_imp.h 7b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* encoding: US-ASCII 8b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* tab size: 8 (not used) 9b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* indentation:4 10b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* 11b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* created on: 2001jan30 12b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru* created by: Markus W. Scherer 13b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru*/ 14b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 15b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef __USTR_IMP_H__ 16b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#define __USTR_IMP_H__ 17b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 18b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/utypes.h" 19b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "unicode/uiter.h" 20b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#include "ucase.h" 21b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 22b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. */ 23b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef UBRK_TYPEDEF_UBREAK_ITERATOR 24b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru# define UBRK_TYPEDEF_UBREAK_ITERATOR 2550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho typedef struct UBreakIterator UBreakIterator; 26b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 27b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 2850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#ifndef U_COMPARE_IGNORE_CASE 2950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/* see also unorm.h */ 3050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/** 3150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Option bit for unorm_compare: 3250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Perform case-insensitive comparison. 3350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @draft ICU 2.2 3450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 3550294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#define U_COMPARE_IGNORE_CASE 0x10000 3650294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#endif 3750294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 3850294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho/** 3950294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Internal option for unorm_cmpEquivFold() for strncmp style. 4050294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * If set, checks for both string length and terminating NUL. 4150294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * @internal 4250294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho */ 4350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho#define _STRNCMP_STYLE 0x1000 4450294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho 45b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 46b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare two strings in code point order or code unit order. 47b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Works in strcmp style (both lengths -1), 48b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * strncmp style (lengths equal and >=0, flag TRUE), 49b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * and memcmp/UnicodeString style (at least one length >=0). 50b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 51b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 52c69afcec261fc345fda8daf46f0ea6b4351dc777Jean-Baptiste QueruU_CFUNC int32_t U_EXPORT2 53b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuprv_strCompare(const UChar *s1, int32_t length1, 54b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *s2, int32_t length2, 55b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBool strncmpStyle, UBool codePointOrder); 56b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 57b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 58b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Internal API, used by u_strcasecmp() etc. 59b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Compare strings case-insensitively, 60b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * in code point order or code unit order. 61b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 62b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 63b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC int32_t 64b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruu_strcmpFold(const UChar *s1, int32_t length1, 65b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *s2, int32_t length2, 66b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options, 67b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *pErrorCode); 68b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 69b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 70b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Are the Unicode properties loaded? 71b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * This must be used before internal functions are called that do 72b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * not perform this check. 7350294ead5e5d23f5bbfed76e00e6b510bd41eee1claireho * Generate a debug assertion failure if data is not loaded. 74b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 75b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 76b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC UBool 77b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuprv_haveProperties(UErrorCode *pErrorCode); 78b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 79b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 80b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Load the Unicode property data. 81b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Intended primarily for use from u_init(). 82b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Has no effect if property data is already loaded. 83b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * NOT thread safe. 84b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 85b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 86b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/*U_CFUNC int8_t 87b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruuprv_loadPropsData(UErrorCode *errorCode);*/ 88b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 89b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/* 90b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Internal string casing functions implementing 91b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * ustring.h/ustrcase.c and UnicodeString case mapping functions. 92b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 93b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 94b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 95b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 96b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 97b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querustruct UCaseMap { 98b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UCaseProps *csp; 99b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_BREAK_ITERATION 100b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBreakIterator *iter; /* We adopt the iterator, so we own it. */ 101b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 102b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru char locale[32]; 103b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru int32_t locCache; 104b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options; 105b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 106b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 107b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#ifndef __UCASEMAP_H__ 108b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Querutypedef struct UCaseMap UCaseMap; 109b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 110b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 111b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 112b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 113b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 114b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruenum { 115b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru TO_LOWER, 116b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru TO_UPPER, 117b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru TO_TITLE, 118b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru FOLD_CASE 119b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru}; 120b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 121b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 122b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 123b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 124b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC int32_t 125b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruustr_toLower(const UCaseProps *csp, 126b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dest, int32_t destCapacity, 127b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *src, int32_t srcLength, 128b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *locale, 129b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *pErrorCode); 130b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 131b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 132b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 133b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 134b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC int32_t 135b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruustr_toUpper(const UCaseProps *csp, 136b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dest, int32_t destCapacity, 137b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *src, int32_t srcLength, 138b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *locale, 139b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *pErrorCode); 140b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 141b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#if !UCONFIG_NO_BREAK_ITERATION 142b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 143b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 144b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 145b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 146b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC int32_t 147b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruustr_toTitle(const UCaseProps *csp, 148b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dest, int32_t destCapacity, 149b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *src, int32_t srcLength, 150b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UBreakIterator *titleIter, 151b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const char *locale, uint32_t options, 152b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *pErrorCode); 153b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 154b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 155b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 156b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 157b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Internal case folding function. 158b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 159b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 160b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CFUNC int32_t 161b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruustr_foldCase(const UCaseProps *csp, 162b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UChar *dest, int32_t destCapacity, 163b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru const UChar *src, int32_t srcLength, 164b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru uint32_t options, 165b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru UErrorCode *pErrorCode); 166b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 167b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 168b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * NUL-terminate a UChar * string if possible. 169b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If length < destCapacity then NUL-terminate. 170b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING. 171b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * If length > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR. 172b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * 173b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param dest Destination buffer, can be NULL if destCapacity==0. 174b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param destCapacity Number of UChars available at dest. 175b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param length Number of UChars that were (to be) written to dest. 176b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @param pErrorCode ICU error code. 177b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @return length 178b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * @internal 179b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 180b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 181b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruu_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); 182b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 183b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 184b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * NUL-terminate a char * string if possible. 185b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Same as u_terminateUChars() but for a different string type. 186b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 187b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 188b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruu_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); 189b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 190b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 191b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * NUL-terminate a UChar32 * string if possible. 192b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Same as u_terminateUChars() but for a different string type. 193b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 194b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 195b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruu_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); 196b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 197b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru/** 198b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * NUL-terminate a wchar_t * string if possible. 199b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru * Same as u_terminateUChars() but for a different string type. 200b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru */ 201b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 202b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queruu_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode); 203b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru 204b13da9df870a61b11249bf741347908dbea0edd8Jean-Baptiste Queru#endif 205