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