]> git.saurik.com Git - apple/icu.git/blame - icuSources/common/utypes.cpp
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / common / utypes.cpp
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
374ca955
A
3/*
4******************************************************************************
5*
b331163b 6* Copyright (C) 1997-2015, International Business Machines
374ca955
A
7* Corporation and others. All Rights Reserved.
8*
9******************************************************************************
10*
11* FILE NAME : utypes.c (previously putil.c)
12*
13* Date Name Description
14* 10/07/2004 grhoten split from putil.c
15******************************************************************************
16*/
17
18#include "unicode/utypes.h"
19
20/* u_errorName() ------------------------------------------------------------ */
21
22static const char * const
23_uErrorInfoName[U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START]={
24 "U_USING_FALLBACK_WARNING",
25 "U_USING_DEFAULT_WARNING",
26 "U_SAFECLONE_ALLOCATED_WARNING",
27 "U_STATE_OLD_WARNING",
28 "U_STRING_NOT_TERMINATED_WARNING",
29 "U_SORT_KEY_TOO_SHORT_WARNING",
30 "U_AMBIGUOUS_ALIAS_WARNING",
729e4ab9
A
31 "U_DIFFERENT_UCA_VERSION",
32 "U_PLUGIN_CHANGED_LEVEL_WARNING",
374ca955
A
33};
34
35static const char * const
36_uTransErrorName[U_PARSE_ERROR_LIMIT - U_PARSE_ERROR_START]={
37 "U_BAD_VARIABLE_DEFINITION",
38 "U_MALFORMED_RULE",
39 "U_MALFORMED_SET",
40 "U_MALFORMED_SYMBOL_REFERENCE",
41 "U_MALFORMED_UNICODE_ESCAPE",
42 "U_MALFORMED_VARIABLE_DEFINITION",
43 "U_MALFORMED_VARIABLE_REFERENCE",
44 "U_MISMATCHED_SEGMENT_DELIMITERS",
45 "U_MISPLACED_ANCHOR_START",
46 "U_MISPLACED_CURSOR_OFFSET",
47 "U_MISPLACED_QUANTIFIER",
48 "U_MISSING_OPERATOR",
49 "U_MISSING_SEGMENT_CLOSE",
50 "U_MULTIPLE_ANTE_CONTEXTS",
51 "U_MULTIPLE_CURSORS",
52 "U_MULTIPLE_POST_CONTEXTS",
53 "U_TRAILING_BACKSLASH",
54 "U_UNDEFINED_SEGMENT_REFERENCE",
55 "U_UNDEFINED_VARIABLE",
56 "U_UNQUOTED_SPECIAL",
57 "U_UNTERMINATED_QUOTE",
58 "U_RULE_MASK_ERROR",
59 "U_MISPLACED_COMPOUND_FILTER",
60 "U_MULTIPLE_COMPOUND_FILTERS",
61 "U_INVALID_RBT_SYNTAX",
62 "U_INVALID_PROPERTY_PATTERN",
63 "U_MALFORMED_PRAGMA",
64 "U_UNCLOSED_SEGMENT",
65 "U_ILLEGAL_CHAR_IN_SEGMENT",
66 "U_VARIABLE_RANGE_EXHAUSTED",
67 "U_VARIABLE_RANGE_OVERLAP",
68 "U_ILLEGAL_CHARACTER",
69 "U_INTERNAL_TRANSLITERATOR_ERROR",
70 "U_INVALID_ID",
71 "U_INVALID_FUNCTION"
72};
73
74static const char * const
75_uErrorName[U_STANDARD_ERROR_LIMIT]={
76 "U_ZERO_ERROR",
77
78 "U_ILLEGAL_ARGUMENT_ERROR",
79 "U_MISSING_RESOURCE_ERROR",
80 "U_INVALID_FORMAT_ERROR",
81 "U_FILE_ACCESS_ERROR",
82 "U_INTERNAL_PROGRAM_ERROR",
83 "U_MESSAGE_PARSE_ERROR",
84 "U_MEMORY_ALLOCATION_ERROR",
85 "U_INDEX_OUTOFBOUNDS_ERROR",
86 "U_PARSE_ERROR",
87 "U_INVALID_CHAR_FOUND",
88 "U_TRUNCATED_CHAR_FOUND",
89 "U_ILLEGAL_CHAR_FOUND",
90 "U_INVALID_TABLE_FORMAT",
91 "U_INVALID_TABLE_FILE",
92 "U_BUFFER_OVERFLOW_ERROR",
93 "U_UNSUPPORTED_ERROR",
94 "U_RESOURCE_TYPE_MISMATCH",
95 "U_ILLEGAL_ESCAPE_SEQUENCE",
96 "U_UNSUPPORTED_ESCAPE_SEQUENCE",
97 "U_NO_SPACE_AVAILABLE",
98 "U_CE_NOT_FOUND_ERROR",
99 "U_PRIMARY_TOO_LONG_ERROR",
100 "U_STATE_TOO_OLD_ERROR",
101 "U_TOO_MANY_ALIASES_ERROR",
102 "U_ENUM_OUT_OF_SYNC_ERROR",
103 "U_INVARIANT_CONVERSION_ERROR",
104 "U_INVALID_STATE_ERROR",
105 "U_COLLATOR_VERSION_MISMATCH",
73c04bcf
A
106 "U_USELESS_COLLATOR_ERROR",
107 "U_NO_WRITE_PERMISSION"
374ca955
A
108};
109static const char * const
110_uFmtErrorName[U_FMT_PARSE_ERROR_LIMIT - U_FMT_PARSE_ERROR_START] = {
111 "U_UNEXPECTED_TOKEN",
112 "U_MULTIPLE_DECIMAL_SEPARATORS",
113 "U_MULTIPLE_EXPONENTIAL_SYMBOLS",
114 "U_MALFORMED_EXPONENTIAL_PATTERN",
115 "U_MULTIPLE_PERCENT_SYMBOLS",
116 "U_MULTIPLE_PERMILL_SYMBOLS",
117 "U_MULTIPLE_PAD_SPECIFIERS",
118 "U_PATTERN_SYNTAX_ERROR",
119 "U_ILLEGAL_PAD_POSITION",
120 "U_UNMATCHED_BRACES",
121 "U_UNSUPPORTED_PROPERTY",
46f4442e 122 "U_UNSUPPORTED_ATTRIBUTE",
729e4ab9
A
123 "U_ARGUMENT_TYPE_MISMATCH",
124 "U_DUPLICATE_KEYWORD",
125 "U_UNDEFINED_KEYWORD",
126 "U_DEFAULT_KEYWORD_MISSING",
4388f060
A
127 "U_DECIMAL_NUMBER_SYNTAX_ERROR",
128 "U_FORMAT_INEXACT_ERROR"
374ca955
A
129};
130
131static const char * const
132_uBrkErrorName[U_BRK_ERROR_LIMIT - U_BRK_ERROR_START] = {
374ca955
A
133 "U_BRK_INTERNAL_ERROR",
134 "U_BRK_HEX_DIGITS_EXPECTED",
135 "U_BRK_SEMICOLON_EXPECTED",
136 "U_BRK_RULE_SYNTAX",
137 "U_BRK_UNCLOSED_SET",
138 "U_BRK_ASSIGN_ERROR",
139 "U_BRK_VARIABLE_REDFINITION",
140 "U_BRK_MISMATCHED_PAREN",
141 "U_BRK_NEW_LINE_IN_QUOTED_STRING",
142 "U_BRK_UNDEFINED_VARIABLE",
143 "U_BRK_INIT_ERROR",
144 "U_BRK_RULE_EMPTY_SET",
145 "U_BRK_UNRECOGNIZED_OPTION",
146 "U_BRK_MALFORMED_RULE_TAG"
147};
148
149static const char * const
150_uRegexErrorName[U_REGEX_ERROR_LIMIT - U_REGEX_ERROR_START] = {
374ca955
A
151 "U_REGEX_INTERNAL_ERROR",
152 "U_REGEX_RULE_SYNTAX",
153 "U_REGEX_INVALID_STATE",
154 "U_REGEX_BAD_ESCAPE_SEQUENCE",
155 "U_REGEX_PROPERTY_SYNTAX",
156 "U_REGEX_UNIMPLEMENTED",
157 "U_REGEX_MISMATCHED_PAREN",
158 "U_REGEX_NUMBER_TOO_BIG",
159 "U_REGEX_BAD_INTERVAL",
160 "U_REGEX_MAX_LT_MIN",
161 "U_REGEX_INVALID_BACK_REF",
162 "U_REGEX_INVALID_FLAG",
163 "U_REGEX_LOOK_BEHIND_LIMIT",
46f4442e
A
164 "U_REGEX_SET_CONTAINS_STRING",
165 "U_REGEX_OCTAL_TOO_BIG",
166 "U_REGEX_MISSING_CLOSE_BRACKET",
167 "U_REGEX_INVALID_RANGE",
168 "U_REGEX_STACK_OVERFLOW",
169 "U_REGEX_TIME_OUT",
b331163b
A
170 "U_REGEX_STOPPED_BY_CALLER",
171 "U_REGEX_PATTERN_TOO_BIG",
172 "U_REGEX_INVALID_CAPTURE_GROUP_NAME"
374ca955
A
173};
174
175static const char * const
176_uIDNAErrorName[U_IDNA_ERROR_LIMIT - U_IDNA_ERROR_START] = {
73c04bcf
A
177 "U_STRINGPREP_PROHIBITED_ERROR",
178 "U_STRINGPREP_UNASSIGNED_ERROR",
179 "U_STRINGPREP_CHECK_BIDI_ERROR",
180 "U_IDNA_STD3_ASCII_RULES_ERROR",
181 "U_IDNA_ACE_PREFIX_ERROR",
182 "U_IDNA_VERIFICATION_ERROR",
183 "U_IDNA_LABEL_TOO_LONG_ERROR",
46f4442e
A
184 "U_IDNA_ZERO_LENGTH_LABEL_ERROR",
185 "U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR"
374ca955
A
186};
187
729e4ab9
A
188static const char * const
189_uPluginErrorName[U_PLUGIN_ERROR_LIMIT - U_PLUGIN_ERROR_START] = {
190 "U_PLUGIN_TOO_HIGH",
191 "U_PLUGIN_DIDNT_SET_LEVEL",
192};
193
374ca955
A
194U_CAPI const char * U_EXPORT2
195u_errorName(UErrorCode code) {
196 if(U_ZERO_ERROR <= code && code < U_STANDARD_ERROR_LIMIT) {
197 return _uErrorName[code];
198 } else if(U_ERROR_WARNING_START <= code && code < U_ERROR_WARNING_LIMIT) {
199 return _uErrorInfoName[code - U_ERROR_WARNING_START];
200 } else if(U_PARSE_ERROR_START <= code && code < U_PARSE_ERROR_LIMIT){
201 return _uTransErrorName[code - U_PARSE_ERROR_START];
202 } else if(U_FMT_PARSE_ERROR_START <= code && code < U_FMT_PARSE_ERROR_LIMIT){
203 return _uFmtErrorName[code - U_FMT_PARSE_ERROR_START];
204 } else if (U_BRK_ERROR_START <= code && code < U_BRK_ERROR_LIMIT){
205 return _uBrkErrorName[code - U_BRK_ERROR_START];
206 } else if (U_REGEX_ERROR_START <= code && code < U_REGEX_ERROR_LIMIT) {
207 return _uRegexErrorName[code - U_REGEX_ERROR_START];
73c04bcf 208 } else if(U_IDNA_ERROR_START <= code && code < U_IDNA_ERROR_LIMIT) {
374ca955 209 return _uIDNAErrorName[code - U_IDNA_ERROR_START];
729e4ab9
A
210 } else if(U_PLUGIN_ERROR_START <= code && code < U_PLUGIN_ERROR_LIMIT) {
211 return _uPluginErrorName[code - U_PLUGIN_ERROR_START];
374ca955
A
212 } else {
213 return "[BOGUS UErrorCode]";
214 }
215}
216
217/*
218 * Hey, Emacs, please set the following:
219 *
220 * Local Variables:
221 * indent-tabs-mode: nil
222 * End:
223 *
224 */