2 *******************************************************************************
4 * Copyright (C) 1999-2015, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: uinvchar.h
10 * tab size: 8 (not used)
13 * created on: 2004sep14
14 * created by: Markus W. Scherer
16 * Definitions for handling invariant characters, moved here from putil.c
17 * for better modularization.
20 #ifndef __UINVCHAR_H__
21 #define __UINVCHAR_H__
23 #include "unicode/utypes.h"
25 #include "unicode/unistr.h"
29 * Check if a char string only contains invariant characters.
30 * See utypes.h for details.
32 * @param s Input string pointer.
33 * @param length Length of the string, can be -1 if NUL-terminated.
34 * @return TRUE if s contains only invariant characters.
38 U_INTERNAL UBool U_EXPORT2
39 uprv_isInvariantString(const char *s
, int32_t length
);
42 * Check if a Unicode string only contains invariant characters.
43 * See utypes.h for details.
45 * @param s Input string pointer.
46 * @param length Length of the string, can be -1 if NUL-terminated.
47 * @return TRUE if s contains only invariant characters.
51 U_INTERNAL UBool U_EXPORT2
52 uprv_isInvariantUString(const UChar
*s
, int32_t length
);
57 * Check if a UnicodeString only contains invariant characters.
58 * See utypes.h for details.
60 * @param s Input string.
61 * @return TRUE if s contains only invariant characters.
63 U_INTERNAL
inline UBool U_EXPORT2
64 uprv_isInvariantUnicodeString(const icu::UnicodeString
&s
) {
65 return uprv_isInvariantUString(s
.getBuffer(), s
.length());
68 #endif /* __cplusplus */
71 * \def U_UPPER_ORDINAL
72 * Get the ordinal number of an uppercase invariant character
75 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
76 # define U_UPPER_ORDINAL(x) ((x)-'A')
77 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
78 # define U_UPPER_ORDINAL(x) (((x) < 'J') ? ((x)-'A') : \
79 (((x) < 'S') ? ((x)-'J'+9) : \
82 # error Unknown charset family!
86 * Compare two EBCDIC invariant-character strings in ASCII order.
89 U_INTERNAL
int32_t U_EXPORT2
90 uprv_compareInvEbcdicAsAscii(const char *s1
, const char *s2
);
93 * \def uprv_compareInvCharsAsAscii
94 * Compare two invariant-character strings in ASCII order.
97 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
98 # define uprv_compareInvCharsAsAscii(s1, s2) uprv_strcmp(s1, s2)
99 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
100 # define uprv_compareInvCharsAsAscii(s1, s2) uprv_compareInvEbcdicAsAscii(s1, s2)
102 # error Unknown charset family!
106 * Converts an EBCDIC invariant character to lowercase ASCII.
109 U_INTERNAL
char U_EXPORT2
110 uprv_ebcdicToLowercaseAscii(char c
);
113 * \def uprv_invCharToLowercaseAscii
114 * Converts an invariant character to lowercase ASCII.
117 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
118 # define uprv_invCharToLowercaseAscii uprv_asciitolower
119 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
120 # define uprv_invCharToLowercaseAscii uprv_ebcdicToLowercaseAscii
122 # error Unknown charset family!
126 * Copy EBCDIC to ASCII
130 U_INTERNAL
uint8_t* U_EXPORT2
131 uprv_aestrncpy(uint8_t *dst
, const uint8_t *src
, int32_t n
);
135 * Copy ASCII to EBCDIC
139 U_INTERNAL
uint8_t* U_EXPORT2
140 uprv_eastrncpy(uint8_t *dst
, const uint8_t *src
, int32_t n
);