]> git.saurik.com Git - apple/icu.git/blob - icuSources/common/uinvchar.h
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / common / uinvchar.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 * Copyright (C) 1999-2015, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: uinvchar.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:2
14 *
15 * created on: 2004sep14
16 * created by: Markus W. Scherer
17 *
18 * Definitions for handling invariant characters, moved here from putil.c
19 * for better modularization.
20 */
21
22 #ifndef __UINVCHAR_H__
23 #define __UINVCHAR_H__
24
25 #include "unicode/utypes.h"
26 #ifdef __cplusplus
27 #include "unicode/unistr.h"
28 #endif
29
30 /**
31 * Check if a char string only contains invariant characters.
32 * See utypes.h for details.
33 *
34 * @param s Input string pointer.
35 * @param length Length of the string, can be -1 if NUL-terminated.
36 * @return TRUE if s contains only invariant characters.
37 *
38 * @internal (ICU 2.8)
39 */
40 U_INTERNAL UBool U_EXPORT2
41 uprv_isInvariantString(const char *s, int32_t length);
42
43 /**
44 * Check if a Unicode string only contains invariant characters.
45 * See utypes.h for details.
46 *
47 * @param s Input string pointer.
48 * @param length Length of the string, can be -1 if NUL-terminated.
49 * @return TRUE if s contains only invariant characters.
50 *
51 * @internal (ICU 2.8)
52 */
53 U_INTERNAL UBool U_EXPORT2
54 uprv_isInvariantUString(const UChar *s, int32_t length);
55
56 /**
57 * \def U_UPPER_ORDINAL
58 * Get the ordinal number of an uppercase invariant character
59 * @internal
60 */
61 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
62 # define U_UPPER_ORDINAL(x) ((x)-'A')
63 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
64 # define U_UPPER_ORDINAL(x) (((x) < 'J') ? ((x)-'A') : \
65 (((x) < 'S') ? ((x)-'J'+9) : \
66 ((x)-'S'+18)))
67 #else
68 # error Unknown charset family!
69 #endif
70
71 /**
72 * Compare two EBCDIC invariant-character strings in ASCII order.
73 * @internal
74 */
75 U_INTERNAL int32_t U_EXPORT2
76 uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2);
77
78 /**
79 * \def uprv_compareInvCharsAsAscii
80 * Compare two invariant-character strings in ASCII order.
81 * @internal
82 */
83 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
84 # define uprv_compareInvCharsAsAscii(s1, s2) uprv_strcmp(s1, s2)
85 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
86 # define uprv_compareInvCharsAsAscii(s1, s2) uprv_compareInvEbcdicAsAscii(s1, s2)
87 #else
88 # error Unknown charset family!
89 #endif
90
91 /**
92 * Converts an EBCDIC invariant character to lowercase ASCII.
93 * @internal
94 */
95 U_INTERNAL char U_EXPORT2
96 uprv_ebcdicToLowercaseAscii(char c);
97
98 /**
99 * \def uprv_invCharToLowercaseAscii
100 * Converts an invariant character to lowercase ASCII.
101 * @internal
102 */
103 #if U_CHARSET_FAMILY==U_ASCII_FAMILY
104 # define uprv_invCharToLowercaseAscii uprv_asciitolower
105 #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY
106 # define uprv_invCharToLowercaseAscii uprv_ebcdicToLowercaseAscii
107 #else
108 # error Unknown charset family!
109 #endif
110
111 /**
112 * Copy EBCDIC to ASCII
113 * @internal
114 * @see uprv_strncpy
115 */
116 U_INTERNAL uint8_t* U_EXPORT2
117 uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n);
118
119
120 /**
121 * Copy ASCII to EBCDIC
122 * @internal
123 * @see uprv_strncpy
124 */
125 U_INTERNAL uint8_t* U_EXPORT2
126 uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n);
127
128
129
130 #endif