1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru****************************************************************************** 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Copyright (C) 1997-2005, International Business Machines 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru****************************************************************************** 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* File CSTRING.H 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Contains CString interface 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* @author Helena Shih 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Modification History: 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Date Name Description 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 6/17/98 hshih Created. 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 05/03/99 stephen Changed from functions to macros. 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 06/14/99 stephen Added icu_strncat, icu_strncmp, icu_tolower 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru****************************************************************************** 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef CSTRING_H 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define CSTRING_H 1 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/utypes.h" 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <string.h> 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <stdlib.h> 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include <ctype.h> 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strcpy(dst, src) U_STANDARD_CPP_NAMESPACE strcpy(dst, src) 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strncpy(dst, src, size) U_STANDARD_CPP_NAMESPACE strncpy(dst, src, size) 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strlen(str) U_STANDARD_CPP_NAMESPACE strlen(str) 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strcmp(s1, s2) U_STANDARD_CPP_NAMESPACE strcmp(s1, s2) 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strncmp(s1, s2, n) U_STANDARD_CPP_NAMESPACE strncmp(s1, s2, n) 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strcat(dst, src) U_STANDARD_CPP_NAMESPACE strcat(dst, src) 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strncat(dst, src, n) U_STANDARD_CPP_NAMESPACE strncat(dst, src, n) 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strchr(s, c) U_STANDARD_CPP_NAMESPACE strchr(s, c) 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strstr(s, c) U_STANDARD_CPP_NAMESPACE strstr(s, c) 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strrchr(s, c) U_STANDARD_CPP_NAMESPACE strrchr(s, c) 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char U_EXPORT2 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruuprv_toupper(char c); 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char U_EXPORT2 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruuprv_asciitolower(char c); 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char U_EXPORT2 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruuprv_ebcdictolower(char c); 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#if U_CHARSET_FAMILY==U_ASCII_FAMILY 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_tolower uprv_asciitolower 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_tolower uprv_ebcdictolower 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# error U_CHARSET_FAMILY is not valid 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strtod(source, end) U_STANDARD_CPP_NAMESPACE strtod(source, end) 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strtoul(str, end, base) U_STANDARD_CPP_NAMESPACE strtoul(str, end, base) 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define uprv_strtol(str, end, base) U_STANDARD_CPP_NAMESPACE strtol(str, end, base) 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifdef U_WINDOWS 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# if defined(__BORLANDC__) 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE stricmp(str1, str2) 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_strnicmp(str1, str2, n) U_STANDARD_CPP_NAMESPACE strnicmp(str1, str2, n) 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# else 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE _stricmp(str1, str2) 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_strnicmp(str1, str2, n) U_STANDARD_CPP_NAMESPACE _strnicmp(str1, str2, n) 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# endif 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#elif defined(POSIX) 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_stricmp(str1, str2) U_STANDARD_CPP_NAMESPACE strcasecmp(str1, str2) 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_strnicmp(str1, str2, n) U_STANDARD_CPP_NAMESPACE strncasecmp(str1, str2, n) 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#else 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_stricmp(str1, str2) T_CString_stricmp(str1, str2) 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru# define uprv_strnicmp(str1, str2, n) T_CString_strnicmp(str1, str2, n) 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* Conversion from a digit to the character with radix base from 2-19 */ 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* May need to use U_UPPER_ORDINAL*/ 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define T_CString_itosOffset(a) ((a)<=9?('0'+(a)):('A'+(a)-10)) 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char* U_EXPORT2 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruuprv_strdup(const char *src); 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * uprv_malloc n+1 bytes, and copy n bytes from src into the new string. 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Terminate with a null at offset n. If n is -1, works like uprv_strdup 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param src 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param n length of the input string, not including null. 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return new string (owned by caller, use uprv_free to free). 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @internal 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char* U_EXPORT2 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruuprv_strndup(const char *src, int32_t n); 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char* U_EXPORT2 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_CString_toLowerCase(char* str); 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI char* U_EXPORT2 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_CString_toUpperCase(char* str); 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_CString_integerToString(char *buffer, int32_t n, int32_t radix); 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_CString_int64ToString(char *buffer, int64_t n, uint32_t radix); 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int32_t U_EXPORT2 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_CString_stringToInteger(const char *integerString, int32_t radix); 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int U_EXPORT2 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_CString_stricmp(const char *str1, const char *str2); 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_CAPI int U_EXPORT2 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruT_CString_strnicmp(const char *str1, const char *str2, uint32_t n); 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif /* ! CSTRING_H */ 121