1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ****************************************************************************** 5*0e209d39SAndroid Build Coastguard Worker * 6*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 1997-2012, International Business Machines 7*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker ****************************************************************************** 10*0e209d39SAndroid Build Coastguard Worker * 11*0e209d39SAndroid Build Coastguard Worker * File CSTRING.H 12*0e209d39SAndroid Build Coastguard Worker * 13*0e209d39SAndroid Build Coastguard Worker * Contains CString interface 14*0e209d39SAndroid Build Coastguard Worker * 15*0e209d39SAndroid Build Coastguard Worker * @author Helena Shih 16*0e209d39SAndroid Build Coastguard Worker * 17*0e209d39SAndroid Build Coastguard Worker * Modification History: 18*0e209d39SAndroid Build Coastguard Worker * 19*0e209d39SAndroid Build Coastguard Worker * Date Name Description 20*0e209d39SAndroid Build Coastguard Worker * 6/17/98 hshih Created. 21*0e209d39SAndroid Build Coastguard Worker * 05/03/99 stephen Changed from functions to macros. 22*0e209d39SAndroid Build Coastguard Worker * 06/14/99 stephen Added icu_strncat, icu_strncmp, icu_tolower 23*0e209d39SAndroid Build Coastguard Worker * 24*0e209d39SAndroid Build Coastguard Worker ****************************************************************************** 25*0e209d39SAndroid Build Coastguard Worker */ 26*0e209d39SAndroid Build Coastguard Worker 27*0e209d39SAndroid Build Coastguard Worker #ifndef CSTRING_H 28*0e209d39SAndroid Build Coastguard Worker #define CSTRING_H 1 29*0e209d39SAndroid Build Coastguard Worker 30*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 31*0e209d39SAndroid Build Coastguard Worker #include "cmemory.h" 32*0e209d39SAndroid Build Coastguard Worker #include <string.h> 33*0e209d39SAndroid Build Coastguard Worker #include <stdlib.h> 34*0e209d39SAndroid Build Coastguard Worker #include <ctype.h> 35*0e209d39SAndroid Build Coastguard Worker 36*0e209d39SAndroid Build Coastguard Worker #define uprv_strcpy(dst, src) U_STANDARD_CPP_NAMESPACE strcpy(dst, src) 37*0e209d39SAndroid Build Coastguard Worker #define uprv_strlen(str) U_STANDARD_CPP_NAMESPACE strlen(str) 38*0e209d39SAndroid Build Coastguard Worker #define uprv_strcmp(s1, s2) U_STANDARD_CPP_NAMESPACE strcmp(s1, s2) 39*0e209d39SAndroid Build Coastguard Worker #define uprv_strcat(dst, src) U_STANDARD_CPP_NAMESPACE strcat(dst, src) 40*0e209d39SAndroid Build Coastguard Worker #define uprv_strchr(s, c) U_STANDARD_CPP_NAMESPACE strchr(s, c) 41*0e209d39SAndroid Build Coastguard Worker #define uprv_strstr(s, c) U_STANDARD_CPP_NAMESPACE strstr(s, c) 42*0e209d39SAndroid Build Coastguard Worker #define uprv_strrchr(s, c) U_STANDARD_CPP_NAMESPACE strrchr(s, c) 43*0e209d39SAndroid Build Coastguard Worker #define uprv_strncpy(dst, src, size) U_STANDARD_CPP_NAMESPACE strncpy(dst, src, size) 44*0e209d39SAndroid Build Coastguard Worker #define uprv_strncmp(s1, s2, n) U_STANDARD_CPP_NAMESPACE strncmp(s1, s2, n) 45*0e209d39SAndroid Build Coastguard Worker #define uprv_strncat(dst, src, n) U_STANDARD_CPP_NAMESPACE strncat(dst, src, n) 46*0e209d39SAndroid Build Coastguard Worker 47*0e209d39SAndroid Build Coastguard Worker /** 48*0e209d39SAndroid Build Coastguard Worker * Is c an ASCII-repertoire letter a-z or A-Z? 49*0e209d39SAndroid Build Coastguard Worker * Note: The implementation is specific to whether ICU is compiled for 50*0e209d39SAndroid Build Coastguard Worker * an ASCII-based or EBCDIC-based machine. There just does not seem to be a better name for this. 51*0e209d39SAndroid Build Coastguard Worker */ 52*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 53*0e209d39SAndroid Build Coastguard Worker uprv_isASCIILetter(char c); 54*0e209d39SAndroid Build Coastguard Worker 55*0e209d39SAndroid Build Coastguard Worker // NOTE: For u_asciiToUpper that takes a UChar, see ustr_imp.h 56*0e209d39SAndroid Build Coastguard Worker 57*0e209d39SAndroid Build Coastguard Worker U_CAPI char U_EXPORT2 58*0e209d39SAndroid Build Coastguard Worker uprv_toupper(char c); 59*0e209d39SAndroid Build Coastguard Worker 60*0e209d39SAndroid Build Coastguard Worker 61*0e209d39SAndroid Build Coastguard Worker U_CAPI char U_EXPORT2 62*0e209d39SAndroid Build Coastguard Worker uprv_asciitolower(char c); 63*0e209d39SAndroid Build Coastguard Worker 64*0e209d39SAndroid Build Coastguard Worker U_CAPI char U_EXPORT2 65*0e209d39SAndroid Build Coastguard Worker uprv_ebcdictolower(char c); 66*0e209d39SAndroid Build Coastguard Worker 67*0e209d39SAndroid Build Coastguard Worker #if U_CHARSET_FAMILY==U_ASCII_FAMILY 68*0e209d39SAndroid Build Coastguard Worker # define uprv_tolower uprv_asciitolower 69*0e209d39SAndroid Build Coastguard Worker #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY 70*0e209d39SAndroid Build Coastguard Worker # define uprv_tolower uprv_ebcdictolower 71*0e209d39SAndroid Build Coastguard Worker #else 72*0e209d39SAndroid Build Coastguard Worker # error U_CHARSET_FAMILY is not valid 73*0e209d39SAndroid Build Coastguard Worker #endif 74*0e209d39SAndroid Build Coastguard Worker 75*0e209d39SAndroid Build Coastguard Worker #define uprv_strtod(source, end) U_STANDARD_CPP_NAMESPACE strtod(source, end) 76*0e209d39SAndroid Build Coastguard Worker #define uprv_strtoul(str, end, base) U_STANDARD_CPP_NAMESPACE strtoul(str, end, base) 77*0e209d39SAndroid Build Coastguard Worker #define uprv_strtol(str, end, base) U_STANDARD_CPP_NAMESPACE strtol(str, end, base) 78*0e209d39SAndroid Build Coastguard Worker 79*0e209d39SAndroid Build Coastguard Worker /* Conversion from a digit to the character with radix base from 2-19 */ 80*0e209d39SAndroid Build Coastguard Worker /* May need to use U_UPPER_ORDINAL*/ 81*0e209d39SAndroid Build Coastguard Worker #define T_CString_itosOffset(a) ((a)<=9?('0'+(a)):('A'+(a)-10)) 82*0e209d39SAndroid Build Coastguard Worker 83*0e209d39SAndroid Build Coastguard Worker U_CAPI char* U_EXPORT2 84*0e209d39SAndroid Build Coastguard Worker uprv_strdup(const char *src); 85*0e209d39SAndroid Build Coastguard Worker 86*0e209d39SAndroid Build Coastguard Worker /** 87*0e209d39SAndroid Build Coastguard Worker * uprv_malloc n+1 bytes, and copy n bytes from src into the new string. 88*0e209d39SAndroid Build Coastguard Worker * Terminate with a null at offset n. If n is -1, works like uprv_strdup 89*0e209d39SAndroid Build Coastguard Worker * @param src 90*0e209d39SAndroid Build Coastguard Worker * @param n length of the input string, not including null. 91*0e209d39SAndroid Build Coastguard Worker * @return new string (owned by caller, use uprv_free to free). 92*0e209d39SAndroid Build Coastguard Worker * @internal 93*0e209d39SAndroid Build Coastguard Worker */ 94*0e209d39SAndroid Build Coastguard Worker U_CAPI char* U_EXPORT2 95*0e209d39SAndroid Build Coastguard Worker uprv_strndup(const char *src, int32_t n); 96*0e209d39SAndroid Build Coastguard Worker 97*0e209d39SAndroid Build Coastguard Worker U_CAPI char* U_EXPORT2 98*0e209d39SAndroid Build Coastguard Worker T_CString_toLowerCase(char* str); 99*0e209d39SAndroid Build Coastguard Worker 100*0e209d39SAndroid Build Coastguard Worker U_CAPI char* U_EXPORT2 101*0e209d39SAndroid Build Coastguard Worker T_CString_toUpperCase(char* str); 102*0e209d39SAndroid Build Coastguard Worker 103*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 104*0e209d39SAndroid Build Coastguard Worker T_CString_integerToString(char *buffer, int32_t n, int32_t radix); 105*0e209d39SAndroid Build Coastguard Worker 106*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 107*0e209d39SAndroid Build Coastguard Worker T_CString_int64ToString(char *buffer, int64_t n, uint32_t radix); 108*0e209d39SAndroid Build Coastguard Worker 109*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 110*0e209d39SAndroid Build Coastguard Worker T_CString_stringToInteger(const char *integerString, int32_t radix); 111*0e209d39SAndroid Build Coastguard Worker 112*0e209d39SAndroid Build Coastguard Worker /** 113*0e209d39SAndroid Build Coastguard Worker * Case-insensitive, language-independent string comparison 114*0e209d39SAndroid Build Coastguard Worker * limited to the ASCII character repertoire. 115*0e209d39SAndroid Build Coastguard Worker */ 116*0e209d39SAndroid Build Coastguard Worker U_CAPI int U_EXPORT2 117*0e209d39SAndroid Build Coastguard Worker uprv_stricmp(const char *str1, const char *str2); 118*0e209d39SAndroid Build Coastguard Worker 119*0e209d39SAndroid Build Coastguard Worker /** 120*0e209d39SAndroid Build Coastguard Worker * Case-insensitive, language-independent string comparison 121*0e209d39SAndroid Build Coastguard Worker * limited to the ASCII character repertoire. 122*0e209d39SAndroid Build Coastguard Worker */ 123*0e209d39SAndroid Build Coastguard Worker U_CAPI int U_EXPORT2 124*0e209d39SAndroid Build Coastguard Worker uprv_strnicmp(const char *str1, const char *str2, uint32_t n); 125*0e209d39SAndroid Build Coastguard Worker 126*0e209d39SAndroid Build Coastguard Worker #endif /* ! CSTRING_H */ 127