11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci****************************************************************************** 51cb0ef41Sopenharmony_ci* 61cb0ef41Sopenharmony_ci* Copyright (C) 1997-2012, International Business Machines 71cb0ef41Sopenharmony_ci* Corporation and others. All Rights Reserved. 81cb0ef41Sopenharmony_ci* 91cb0ef41Sopenharmony_ci****************************************************************************** 101cb0ef41Sopenharmony_ci* 111cb0ef41Sopenharmony_ci* File CSTRING.H 121cb0ef41Sopenharmony_ci* 131cb0ef41Sopenharmony_ci* Contains CString interface 141cb0ef41Sopenharmony_ci* 151cb0ef41Sopenharmony_ci* @author Helena Shih 161cb0ef41Sopenharmony_ci* 171cb0ef41Sopenharmony_ci* Modification History: 181cb0ef41Sopenharmony_ci* 191cb0ef41Sopenharmony_ci* Date Name Description 201cb0ef41Sopenharmony_ci* 6/17/98 hshih Created. 211cb0ef41Sopenharmony_ci* 05/03/99 stephen Changed from functions to macros. 221cb0ef41Sopenharmony_ci* 06/14/99 stephen Added icu_strncat, icu_strncmp, icu_tolower 231cb0ef41Sopenharmony_ci* 241cb0ef41Sopenharmony_ci****************************************************************************** 251cb0ef41Sopenharmony_ci*/ 261cb0ef41Sopenharmony_ci 271cb0ef41Sopenharmony_ci#ifndef CSTRING_H 281cb0ef41Sopenharmony_ci#define CSTRING_H 1 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 311cb0ef41Sopenharmony_ci#include "cmemory.h" 321cb0ef41Sopenharmony_ci#include <string.h> 331cb0ef41Sopenharmony_ci#include <stdlib.h> 341cb0ef41Sopenharmony_ci#include <ctype.h> 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci#define uprv_strcpy(dst, src) U_STANDARD_CPP_NAMESPACE strcpy(dst, src) 371cb0ef41Sopenharmony_ci#define uprv_strlen(str) U_STANDARD_CPP_NAMESPACE strlen(str) 381cb0ef41Sopenharmony_ci#define uprv_strcmp(s1, s2) U_STANDARD_CPP_NAMESPACE strcmp(s1, s2) 391cb0ef41Sopenharmony_ci#define uprv_strcat(dst, src) U_STANDARD_CPP_NAMESPACE strcat(dst, src) 401cb0ef41Sopenharmony_ci#define uprv_strchr(s, c) U_STANDARD_CPP_NAMESPACE strchr(s, c) 411cb0ef41Sopenharmony_ci#define uprv_strstr(s, c) U_STANDARD_CPP_NAMESPACE strstr(s, c) 421cb0ef41Sopenharmony_ci#define uprv_strrchr(s, c) U_STANDARD_CPP_NAMESPACE strrchr(s, c) 431cb0ef41Sopenharmony_ci#define uprv_strncpy(dst, src, size) U_STANDARD_CPP_NAMESPACE strncpy(dst, src, size) 441cb0ef41Sopenharmony_ci#define uprv_strncmp(s1, s2, n) U_STANDARD_CPP_NAMESPACE strncmp(s1, s2, n) 451cb0ef41Sopenharmony_ci#define uprv_strncat(dst, src, n) U_STANDARD_CPP_NAMESPACE strncat(dst, src, n) 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci/** 481cb0ef41Sopenharmony_ci * Is c an ASCII-repertoire letter a-z or A-Z? 491cb0ef41Sopenharmony_ci * Note: The implementation is specific to whether ICU is compiled for 501cb0ef41Sopenharmony_ci * an ASCII-based or EBCDIC-based machine. There just does not seem to be a better name for this. 511cb0ef41Sopenharmony_ci */ 521cb0ef41Sopenharmony_ciU_CAPI UBool U_EXPORT2 531cb0ef41Sopenharmony_ciuprv_isASCIILetter(char c); 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci// NOTE: For u_asciiToUpper that takes a UChar, see ustr_imp.h 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ciU_CAPI char U_EXPORT2 581cb0ef41Sopenharmony_ciuprv_toupper(char c); 591cb0ef41Sopenharmony_ci 601cb0ef41Sopenharmony_ci 611cb0ef41Sopenharmony_ciU_CAPI char U_EXPORT2 621cb0ef41Sopenharmony_ciuprv_asciitolower(char c); 631cb0ef41Sopenharmony_ci 641cb0ef41Sopenharmony_ciU_CAPI char U_EXPORT2 651cb0ef41Sopenharmony_ciuprv_ebcdictolower(char c); 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci#if U_CHARSET_FAMILY==U_ASCII_FAMILY 681cb0ef41Sopenharmony_ci# define uprv_tolower uprv_asciitolower 691cb0ef41Sopenharmony_ci#elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY 701cb0ef41Sopenharmony_ci# define uprv_tolower uprv_ebcdictolower 711cb0ef41Sopenharmony_ci#else 721cb0ef41Sopenharmony_ci# error U_CHARSET_FAMILY is not valid 731cb0ef41Sopenharmony_ci#endif 741cb0ef41Sopenharmony_ci 751cb0ef41Sopenharmony_ci#define uprv_strtod(source, end) U_STANDARD_CPP_NAMESPACE strtod(source, end) 761cb0ef41Sopenharmony_ci#define uprv_strtoul(str, end, base) U_STANDARD_CPP_NAMESPACE strtoul(str, end, base) 771cb0ef41Sopenharmony_ci#define uprv_strtol(str, end, base) U_STANDARD_CPP_NAMESPACE strtol(str, end, base) 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_ci/* Conversion from a digit to the character with radix base from 2-19 */ 801cb0ef41Sopenharmony_ci/* May need to use U_UPPER_ORDINAL*/ 811cb0ef41Sopenharmony_ci#define T_CString_itosOffset(a) ((a)<=9?('0'+(a)):('A'+(a)-10)) 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ciU_CAPI char* U_EXPORT2 841cb0ef41Sopenharmony_ciuprv_strdup(const char *src); 851cb0ef41Sopenharmony_ci 861cb0ef41Sopenharmony_ci/** 871cb0ef41Sopenharmony_ci * uprv_malloc n+1 bytes, and copy n bytes from src into the new string. 881cb0ef41Sopenharmony_ci * Terminate with a null at offset n. If n is -1, works like uprv_strdup 891cb0ef41Sopenharmony_ci * @param src 901cb0ef41Sopenharmony_ci * @param n length of the input string, not including null. 911cb0ef41Sopenharmony_ci * @return new string (owned by caller, use uprv_free to free). 921cb0ef41Sopenharmony_ci * @internal 931cb0ef41Sopenharmony_ci */ 941cb0ef41Sopenharmony_ciU_CAPI char* U_EXPORT2 951cb0ef41Sopenharmony_ciuprv_strndup(const char *src, int32_t n); 961cb0ef41Sopenharmony_ci 971cb0ef41Sopenharmony_ciU_CAPI char* U_EXPORT2 981cb0ef41Sopenharmony_ciT_CString_toLowerCase(char* str); 991cb0ef41Sopenharmony_ci 1001cb0ef41Sopenharmony_ciU_CAPI char* U_EXPORT2 1011cb0ef41Sopenharmony_ciT_CString_toUpperCase(char* str); 1021cb0ef41Sopenharmony_ci 1031cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2 1041cb0ef41Sopenharmony_ciT_CString_integerToString(char *buffer, int32_t n, int32_t radix); 1051cb0ef41Sopenharmony_ci 1061cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2 1071cb0ef41Sopenharmony_ciT_CString_int64ToString(char *buffer, int64_t n, uint32_t radix); 1081cb0ef41Sopenharmony_ci 1091cb0ef41Sopenharmony_ciU_CAPI int32_t U_EXPORT2 1101cb0ef41Sopenharmony_ciT_CString_stringToInteger(const char *integerString, int32_t radix); 1111cb0ef41Sopenharmony_ci 1121cb0ef41Sopenharmony_ci/** 1131cb0ef41Sopenharmony_ci * Case-insensitive, language-independent string comparison 1141cb0ef41Sopenharmony_ci * limited to the ASCII character repertoire. 1151cb0ef41Sopenharmony_ci */ 1161cb0ef41Sopenharmony_ciU_CAPI int U_EXPORT2 1171cb0ef41Sopenharmony_ciuprv_stricmp(const char *str1, const char *str2); 1181cb0ef41Sopenharmony_ci 1191cb0ef41Sopenharmony_ci/** 1201cb0ef41Sopenharmony_ci * Case-insensitive, language-independent string comparison 1211cb0ef41Sopenharmony_ci * limited to the ASCII character repertoire. 1221cb0ef41Sopenharmony_ci */ 1231cb0ef41Sopenharmony_ciU_CAPI int U_EXPORT2 1241cb0ef41Sopenharmony_ciuprv_strnicmp(const char *str1, const char *str2, uint32_t n); 1251cb0ef41Sopenharmony_ci 1261cb0ef41Sopenharmony_ci#endif /* ! CSTRING_H */ 127