1 /*
2 +----------------------------------------------------------------------+
3 | PHP Version 5 |
4 +----------------------------------------------------------------------+
5 | This source file is subject to version 3.01 of the PHP license, |
6 | that is bundled with this package in the file LICENSE, and is |
7 | available through the world-wide-web at the following url: |
8 | http://www.php.net/license/3_01.txt |
9 | If you did not receive a copy of the PHP license and are unable to |
10 | obtain it through the world-wide-web, please send a note to |
11 | license@php.net so we can mail you a copy immediately. |
12 +----------------------------------------------------------------------+
13 | Authors: Vadim Savchuk <vsavchuk@productengine.com> |
14 | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
15 | Stanislav Malyshev <stas@zend.com> |
16 | Kirti Velankar <kirtig@yahoo-inc.com> |
17 +----------------------------------------------------------------------+
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23
24
25 #include "php_intl.h"
26 #include "intl_error.h"
27 #include "collator/collator_class.h"
28 #include "collator/collator.h"
29 #include "collator/collator_attr.h"
30 #include "collator/collator_compare.h"
31 #include "collator/collator_sort.h"
32 #include "collator/collator_convert.h"
33 #include "collator/collator_locale.h"
34 #include "collator/collator_create.h"
35 #include "collator/collator_error.h"
36
37 #include "formatter/formatter.h"
38 #include "formatter/formatter_class.h"
39 #include "formatter/formatter_attr.h"
40 #include "formatter/formatter_format.h"
41 #include "formatter/formatter_main.h"
42 #include "formatter/formatter_parse.h"
43
44 #include "msgformat/msgformat.h"
45 #include "msgformat/msgformat_class.h"
46 #include "msgformat/msgformat_attr.h"
47 #include "msgformat/msgformat_format.h"
48 #include "msgformat/msgformat_parse.h"
49
50 #include "normalizer/normalizer.h"
51 #include "normalizer/normalizer_class.h"
52 #include "normalizer/normalizer_normalize.h"
53
54 #include "locale/locale.h"
55 #include "locale/locale_class.h"
56 #include "locale/locale_methods.h"
57
58 #include "dateformat/dateformat.h"
59 #include "dateformat/dateformat_class.h"
60 #include "dateformat/dateformat_attr.h"
61 #include "dateformat/dateformat_format.h"
62 #include "dateformat/dateformat_parse.h"
63 #include "dateformat/dateformat_data.h"
64
65 #include "resourcebundle/resourcebundle_class.h"
66
67 #include "transliterator/transliterator.h"
68 #include "transliterator/transliterator_class.h"
69 #include "transliterator/transliterator_methods.h"
70
71 #include "idn/idn.h"
72
73 #if U_ICU_VERSION_MAJOR_NUM * 1000 + U_ICU_VERSION_MINOR_NUM >= 4002
74 # include "spoofchecker/spoofchecker_class.h"
75 # include "spoofchecker/spoofchecker.h"
76 # include "spoofchecker/spoofchecker_create.h"
77 # include "spoofchecker/spoofchecker_main.h"
78 #endif
79
80 #include "msgformat/msgformat.h"
81 #include "common/common_error.h"
82
83 #include <unicode/uloc.h>
84 #include <ext/standard/info.h>
85
86 #include "php_ini.h"
87 #define INTL_MODULE_VERSION PHP_INTL_VERSION
88
89 /*
90 * locale_get_default has a conflict since ICU also has
91 * a function with the same name
92 * in fact ICU appends the version no. to it also
93 * Hence the following undef for ICU version
94 * Same true for the locale_set_default function
95 */
96 #undef locale_get_default
97 #undef locale_set_default
98
99 ZEND_DECLARE_MODULE_GLOBALS( intl )
100
101 /* {{{ Arguments info */
102 ZEND_BEGIN_ARG_INFO_EX(collator_static_0_args, 0, 0, 0)
103 ZEND_END_ARG_INFO()
104
105 ZEND_BEGIN_ARG_INFO_EX(collator_static_1_arg, 0, 0, 1)
106 ZEND_ARG_INFO(0, arg1)
107 ZEND_END_ARG_INFO()
108
109 ZEND_BEGIN_ARG_INFO_EX(collator_static_2_args, 0, 0, 2)
110 ZEND_ARG_INFO(0, arg1)
111 ZEND_ARG_INFO(0, arg2)
112 ZEND_END_ARG_INFO()
113
114 ZEND_BEGIN_ARG_INFO_EX(collator_0_args, 0, 0, 1)
115 ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
116 ZEND_END_ARG_INFO()
117
118 ZEND_BEGIN_ARG_INFO_EX(collator_1_arg, 0, 0, 2)
119 ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
120 ZEND_ARG_INFO(0, arg1)
121 ZEND_END_ARG_INFO()
122
123 ZEND_BEGIN_ARG_INFO_EX(collator_2_args, 0, 0, 3)
124 ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
125 ZEND_ARG_INFO(0, arg1)
126 ZEND_ARG_INFO(0, arg2)
127 ZEND_END_ARG_INFO()
128
129 ZEND_BEGIN_ARG_INFO_EX(collator_sort_args, 0, 0, 2)
130 ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
131 ZEND_ARG_ARRAY_INFO(1, arr, 0)
132 ZEND_ARG_INFO(0, sort_flags)
133 ZEND_END_ARG_INFO()
134
135 ZEND_BEGIN_ARG_INFO_EX(numfmt_parse_arginfo, 0, 0, 2)
136 ZEND_ARG_INFO(0, formatter)
137 ZEND_ARG_INFO(0, string)
138 ZEND_ARG_INFO(0, type)
139 ZEND_ARG_INFO(1, position)
140 ZEND_END_ARG_INFO()
141
142 ZEND_BEGIN_ARG_INFO_EX(numfmt_parse_currency_arginfo, 0, 0, 3)
143 ZEND_ARG_INFO(0, formatter)
144 ZEND_ARG_INFO(0, string)
145 ZEND_ARG_INFO(1, currency)
146 ZEND_ARG_INFO(1, position)
147 ZEND_END_ARG_INFO()
148
149 ZEND_BEGIN_ARG_INFO_EX(locale_0_args, 0, 0, 0)
150 ZEND_END_ARG_INFO()
151
152 ZEND_BEGIN_ARG_INFO_EX(locale_1_arg, 0, 0, 1)
153 ZEND_ARG_INFO(0, arg1)
154 ZEND_END_ARG_INFO()
155
156 ZEND_BEGIN_ARG_INFO_EX(locale_2_args, 0, 0, 2)
157 ZEND_ARG_INFO(0, arg1)
158 ZEND_ARG_INFO(0, arg2)
159 ZEND_END_ARG_INFO()
160
161 ZEND_BEGIN_ARG_INFO_EX(locale_3_args, 0, 0, 3)
162 ZEND_ARG_INFO(0, arg1)
163 ZEND_ARG_INFO(0, arg2)
164 ZEND_ARG_INFO(0, arg3)
165 ZEND_END_ARG_INFO()
166
167 ZEND_BEGIN_ARG_INFO_EX(locale_4_args, 0, 0, 4)
168 ZEND_ARG_INFO(0, arg1)
169 ZEND_ARG_INFO(0, arg2)
170 ZEND_ARG_INFO(0, arg3)
171 ZEND_ARG_INFO(0, arg4)
172 ZEND_END_ARG_INFO()
173
174 #define intl_0_args collator_static_0_args
175 #define intl_1_arg collator_static_1_arg
176
177 ZEND_BEGIN_ARG_INFO_EX(normalizer_args, 0, 0, 1)
178 ZEND_ARG_INFO(0, input)
179 ZEND_ARG_INFO(0, form)
180 ZEND_END_ARG_INFO()
181
182 ZEND_BEGIN_ARG_INFO_EX(grapheme_1_arg, 0, 0, 1)
183 ZEND_ARG_INFO(0, string)
184 ZEND_END_ARG_INFO()
185
186 ZEND_BEGIN_ARG_INFO_EX(grapheme_search_args, 0, 0, 2)
187 ZEND_ARG_INFO(0, haystack)
188 ZEND_ARG_INFO(0, needle)
189 ZEND_ARG_INFO(0, offset)
190 ZEND_END_ARG_INFO()
191
192 ZEND_BEGIN_ARG_INFO_EX(grapheme_substr_args, 0, 0, 2)
193 ZEND_ARG_INFO(0, string)
194 ZEND_ARG_INFO(0, start)
195 ZEND_ARG_INFO(0, length)
196 ZEND_END_ARG_INFO()
197
198 ZEND_BEGIN_ARG_INFO_EX(grapheme_strstr_args, 0, 0, 2)
199 ZEND_ARG_INFO(0, haystack)
200 ZEND_ARG_INFO(0, needle)
201 ZEND_ARG_INFO(0, before_needle)
202 ZEND_END_ARG_INFO()
203
204 ZEND_BEGIN_ARG_INFO_EX(grapheme_extract_args, 0, 0, 2)
205 ZEND_ARG_INFO(0, arg1)
206 ZEND_ARG_INFO(0, arg2)
207 ZEND_ARG_INFO(0, arg3)
208 ZEND_ARG_INFO(0, arg4)
209 ZEND_ARG_INFO(1, arg5) /* 1 = pass by reference */
210 ZEND_END_ARG_INFO()
211
212 ZEND_BEGIN_ARG_INFO_EX(datefmt_parse_args, 0, 0, 2)
213 ZEND_ARG_INFO(0, formatter)
214 ZEND_ARG_INFO(0, string)
215 ZEND_ARG_INFO(1, position)
216 ZEND_END_ARG_INFO()
217
218 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_create, 0, 0, 2)
219 ZEND_ARG_INFO(0, locale)
220 ZEND_ARG_INFO(0, style)
221 ZEND_ARG_INFO(0, pattern)
222 ZEND_END_ARG_INFO()
223
224 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_error_code, 0, 0, 1)
225 ZEND_ARG_INFO(0, nf)
226 ZEND_END_ARG_INFO()
227
228 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format, 0, 0, 2)
229 ZEND_ARG_INFO(0, nf)
230 ZEND_ARG_INFO(0, num)
231 ZEND_ARG_INFO(0, type)
232 ZEND_END_ARG_INFO()
233
234 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format_currency, 0, 0, 3)
235 ZEND_ARG_INFO(0, nf)
236 ZEND_ARG_INFO(0, num)
237 ZEND_ARG_INFO(0, currency)
238 ZEND_END_ARG_INFO()
239
240 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_attribute, 0, 0, 2)
241 ZEND_ARG_INFO(0, nf)
242 ZEND_ARG_INFO(0, attr)
243 ZEND_END_ARG_INFO()
244
245 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_attribute, 0, 0, 3)
246 ZEND_ARG_INFO(0, nf)
247 ZEND_ARG_INFO(0, attr)
248 ZEND_ARG_INFO(0, value)
249 ZEND_END_ARG_INFO()
250
251 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_symbol, 0, 0, 3)
252 ZEND_ARG_INFO(0, nf)
253 ZEND_ARG_INFO(0, attr)
254 ZEND_ARG_INFO(0, symbol)
255 ZEND_END_ARG_INFO()
256
257 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_pattern, 0, 0, 2)
258 ZEND_ARG_INFO(0, nf)
259 ZEND_ARG_INFO(0, pattern)
260 ZEND_END_ARG_INFO()
261
262 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_locale, 0, 0, 1)
263 ZEND_ARG_INFO(0, nf)
264 ZEND_ARG_INFO(0, type)
265 ZEND_END_ARG_INFO()
266
267 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_create, 0, 0, 2)
268 ZEND_ARG_INFO(0, locale)
269 ZEND_ARG_INFO(0, pattern)
270 ZEND_END_ARG_INFO()
271
272 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_error_code, 0, 0, 1)
273 ZEND_ARG_INFO(0, nf)
274 ZEND_END_ARG_INFO()
275
276 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_error_message, 0, 0, 1)
277 ZEND_ARG_INFO(0, coll)
278 ZEND_END_ARG_INFO()
279
280 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_format, 0, 0, 2)
281 ZEND_ARG_INFO(0, nf)
282 ZEND_ARG_INFO(0, args)
283 ZEND_END_ARG_INFO()
284
285 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_format_message, 0, 0, 3)
286 ZEND_ARG_INFO(0, locale)
287 ZEND_ARG_INFO(0, pattern)
288 ZEND_ARG_INFO(0, args)
289 ZEND_END_ARG_INFO()
290
291 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_parse, 0, 0, 2)
292 ZEND_ARG_INFO(0, nf)
293 ZEND_ARG_INFO(0, source)
294 ZEND_END_ARG_INFO()
295
296 ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_parse_message, 0, 0, 3)
297 ZEND_ARG_INFO(0, locale)
298 ZEND_ARG_INFO(0, pattern)
299 ZEND_ARG_INFO(0, source)
300 ZEND_END_ARG_INFO()
301
302 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_set_pattern, 0, 0, 2)
303 ZEND_ARG_INFO(0, mf)
304 ZEND_ARG_INFO(0, pattern)
305 ZEND_END_ARG_INFO()
306
307 ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_locale, 0, 0, 1)
308 ZEND_ARG_INFO(0, mf)
309 ZEND_END_ARG_INFO()
310
311 ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_pattern, 0, 0, 2)
312 ZEND_ARG_INFO(0, mf)
313 ZEND_ARG_INFO(0, pattern)
314 ZEND_END_ARG_INFO()
315
316 ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_calendar, 0, 0, 2)
317 ZEND_ARG_INFO(0, mf)
318 ZEND_ARG_INFO(0, calendar)
319 ZEND_END_ARG_INFO()
320
321 ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_format, 0, 0, 0)
322 ZEND_ARG_INFO(0, args)
323 ZEND_ARG_INFO(0, array)
324 ZEND_END_ARG_INFO()
325
326 ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_create, 0, 0, 3)
327 ZEND_ARG_INFO(0, locale)
328 ZEND_ARG_INFO(0, date_type)
329 ZEND_ARG_INFO(0, time_type)
330 ZEND_ARG_INFO(0, timezone_str)
331 ZEND_ARG_INFO(0, calendar)
332 ZEND_ARG_INFO(0, pattern)
333 ZEND_END_ARG_INFO()
334
335 ZEND_BEGIN_ARG_INFO_EX(arginfo_idn_to_ascii, 0, 0, 1)
336 ZEND_ARG_INFO(0, domain)
337 ZEND_ARG_INFO(0, option)
338 ZEND_ARG_INFO(0, variant)
339 ZEND_ARG_INFO(1, idn_info)
340 ZEND_END_ARG_INFO()
341
342 ZEND_BEGIN_ARG_INFO_EX(arginfo_idn_to_utf8, 0, 0, 1)
343 ZEND_ARG_INFO(0, domain)
344 ZEND_ARG_INFO(0, option)
345 ZEND_ARG_INFO(0, variant)
346 ZEND_ARG_INFO(1, idn_info)
347 ZEND_END_ARG_INFO()
348
349 ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_create_proc, 0, 0, 2 )
350 ZEND_ARG_INFO( 0, locale )
351 ZEND_ARG_INFO( 0, bundlename )
352 ZEND_ARG_INFO( 0, fallback )
353 ZEND_END_ARG_INFO()
354
355 ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_proc, 0, 0, 2 )
356 ZEND_ARG_INFO( 0, bundle )
357 ZEND_ARG_INFO( 0, index )
358 ZEND_ARG_INFO( 0, fallback )
359 ZEND_END_ARG_INFO()
360
361 ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_count_proc, 0, 0, 1 )
362 ZEND_ARG_INFO( 0, bundle )
363 ZEND_END_ARG_INFO()
364
365 ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_locales_proc, 0, 0, 1 )
366 ZEND_ARG_INFO( 0, bundlename )
367 ZEND_END_ARG_INFO()
368
369 ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_code_proc, 0, 0, 1 )
370 ZEND_ARG_INFO( 0, bundle )
371 ZEND_END_ARG_INFO()
372
373 ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_message_proc, 0, 0, 1 )
374 ZEND_ARG_INFO( 0, bundle )
375 ZEND_END_ARG_INFO()
376
377 ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_void, 0, 0, 0 )
378 ZEND_END_ARG_INFO()
379
380 ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_create, 0, 0, 1 )
381 ZEND_ARG_INFO( 0, id )
382 ZEND_ARG_INFO( 0, direction )
383 ZEND_END_ARG_INFO()
384
385 ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_create_from_rules, 0, 0, 1 )
386 ZEND_ARG_INFO( 0, rules )
387 ZEND_ARG_INFO( 0, direction )
388 ZEND_END_ARG_INFO()
389
390 ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_create_inverse, 0, 0, 1 )
391 ZEND_ARG_OBJ_INFO( 0, orig_trans, Transliterator, 0 )
392 ZEND_END_ARG_INFO()
393
394 ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_transliterate, 0, 0, 2 )
395 ZEND_ARG_INFO( 0, trans )
396 ZEND_ARG_INFO( 0, subject )
397 ZEND_ARG_INFO( 0, start )
398 ZEND_ARG_INFO( 0, end )
399 ZEND_END_ARG_INFO()
400
401 ZEND_BEGIN_ARG_INFO_EX( arginfo_transliterator_error, 0, 0, 1 )
402 ZEND_ARG_OBJ_INFO( 0, trans, Transliterator, 0 )
403 ZEND_END_ARG_INFO()
404
405 /* }}} */
406
407 /* {{{ intl_functions
408 *
409 * Every user visible function must have an entry in intl_functions[].
410 */
411 zend_function_entry intl_functions[] = {
412
413 /* collator functions */
414 PHP_FE( collator_create, collator_static_1_arg )
415 PHP_FE( collator_compare, collator_2_args )
416 PHP_FE( collator_get_attribute, collator_1_arg )
417 PHP_FE( collator_set_attribute, collator_2_args )
418 PHP_FE( collator_get_strength, collator_0_args )
419 PHP_FE( collator_set_strength, collator_1_arg )
420 PHP_FE( collator_sort, collator_sort_args )
421 PHP_FE( collator_sort_with_sort_keys, collator_sort_args )
422 PHP_FE( collator_asort, collator_sort_args )
423 PHP_FE( collator_get_locale, collator_1_arg )
424 PHP_FE( collator_get_error_code, collator_0_args )
425 PHP_FE( collator_get_error_message, collator_0_args )
426 PHP_FE( collator_get_sort_key, collator_2_args )
427
428 /* formatter functions */
429 PHP_FE( numfmt_create, arginfo_numfmt_create )
430 PHP_FE( numfmt_format, arginfo_numfmt_format )
431 PHP_FE( numfmt_parse, numfmt_parse_arginfo )
432 PHP_FE( numfmt_format_currency, arginfo_numfmt_format_currency )
433 PHP_FE( numfmt_parse_currency, numfmt_parse_currency_arginfo )
434 PHP_FE( numfmt_set_attribute, arginfo_numfmt_set_attribute )
435 PHP_FE( numfmt_get_attribute, arginfo_numfmt_get_attribute )
436 PHP_FE( numfmt_set_text_attribute, arginfo_numfmt_set_attribute )
437 PHP_FE( numfmt_get_text_attribute, arginfo_numfmt_get_attribute )
438 PHP_FE( numfmt_set_symbol, arginfo_numfmt_set_symbol )
439 PHP_FE( numfmt_get_symbol, arginfo_numfmt_get_attribute )
440 PHP_FE( numfmt_set_pattern, arginfo_numfmt_set_pattern )
441 PHP_FE( numfmt_get_pattern, arginfo_numfmt_get_error_code )
442 PHP_FE( numfmt_get_locale, arginfo_numfmt_get_locale )
443 PHP_FE( numfmt_get_error_code, arginfo_numfmt_get_error_code )
444 PHP_FE( numfmt_get_error_message, arginfo_numfmt_get_error_code )
445
446 /* normalizer functions */
447 PHP_FE( normalizer_normalize, normalizer_args )
448 PHP_FE( normalizer_is_normalized, normalizer_args )
449
450 /* Locale functions */
451 PHP_NAMED_FE( locale_get_default, zif_locale_get_default, locale_0_args )
452 PHP_NAMED_FE( locale_set_default, zif_locale_set_default, locale_1_arg )
453 PHP_FE( locale_get_primary_language, locale_1_arg )
454 PHP_FE( locale_get_script, locale_1_arg )
455 PHP_FE( locale_get_region, locale_1_arg )
456 PHP_FE( locale_get_keywords, locale_1_arg )
457 PHP_FE( locale_get_display_script, locale_2_args )
458 PHP_FE( locale_get_display_region, locale_2_args )
459 PHP_FE( locale_get_display_name, locale_2_args )
460 PHP_FE( locale_get_display_language, locale_2_args)
461 PHP_FE( locale_get_display_variant, locale_2_args )
462 PHP_FE( locale_compose, locale_1_arg )
463 PHP_FE( locale_parse, locale_1_arg )
464 PHP_FE( locale_get_all_variants, locale_1_arg )
465 PHP_FE( locale_filter_matches, locale_3_args )
466 PHP_FE( locale_canonicalize, locale_1_arg )
467 PHP_FE( locale_lookup, locale_4_args )
468 PHP_FE( locale_accept_from_http, locale_1_arg )
469
470 /* MessageFormatter functions */
471 PHP_FE( msgfmt_create, arginfo_msgfmt_create )
472 PHP_FE( msgfmt_format, arginfo_msgfmt_format )
473 PHP_FE( msgfmt_format_message, arginfo_msgfmt_format_message )
474 PHP_FE( msgfmt_parse, arginfo_msgfmt_parse )
475 PHP_FE( msgfmt_parse_message, arginfo_numfmt_parse_message )
476 PHP_FE( msgfmt_set_pattern, arginfo_msgfmt_set_pattern )
477 PHP_FE( msgfmt_get_pattern, arginfo_msgfmt_get_locale )
478 PHP_FE( msgfmt_get_locale, arginfo_msgfmt_get_locale )
479 PHP_FE( msgfmt_get_error_code, arginfo_msgfmt_get_error_code )
480 PHP_FE( msgfmt_get_error_message, arginfo_msgfmt_get_error_message )
481
482 /* IntlDateFormatter functions */
483 PHP_FE( datefmt_create, arginfo_datefmt_create )
484 PHP_FE( datefmt_get_datetype, arginfo_msgfmt_get_locale )
485 PHP_FE( datefmt_get_timetype, arginfo_msgfmt_get_locale )
486 PHP_FE( datefmt_get_calendar, arginfo_msgfmt_get_locale )
487 PHP_FE( datefmt_set_calendar, arginfo_datefmt_set_calendar )
488 PHP_FE( datefmt_get_locale, arginfo_msgfmt_get_locale )
489 PHP_FE( datefmt_get_timezone_id, arginfo_msgfmt_get_locale )
490 PHP_FE( datefmt_set_timezone_id, arginfo_msgfmt_get_locale )
491 PHP_FE( datefmt_get_pattern, arginfo_msgfmt_get_locale )
492 PHP_FE( datefmt_set_pattern, arginfo_datefmt_set_pattern )
493 PHP_FE( datefmt_is_lenient, arginfo_msgfmt_get_locale )
494 PHP_FE( datefmt_set_lenient, arginfo_msgfmt_get_locale )
495 PHP_FE( datefmt_format, arginfo_datefmt_format )
496 PHP_FE( datefmt_parse, datefmt_parse_args )
497 PHP_FE( datefmt_localtime , datefmt_parse_args )
498 PHP_FE( datefmt_get_error_code, arginfo_msgfmt_get_error_code )
499 PHP_FE( datefmt_get_error_message, arginfo_msgfmt_get_error_message )
500
501 /* grapheme functions */
502 PHP_FE( grapheme_strlen, grapheme_1_arg )
503 PHP_FE( grapheme_strpos, grapheme_search_args )
504 PHP_FE( grapheme_stripos, grapheme_search_args )
505 PHP_FE( grapheme_strrpos, grapheme_search_args )
506 PHP_FE( grapheme_strripos, grapheme_search_args )
507 PHP_FE( grapheme_substr, grapheme_substr_args )
508 PHP_FE( grapheme_strstr, grapheme_strstr_args )
509 PHP_FE( grapheme_stristr, grapheme_strstr_args )
510 PHP_FE( grapheme_extract, grapheme_extract_args )
511
512 /* IDN functions */
513 PHP_FE( idn_to_ascii, arginfo_idn_to_ascii)
514 PHP_FE( idn_to_utf8, arginfo_idn_to_ascii)
515
516 /* ResourceBundle functions */
517 PHP_FE( resourcebundle_create, arginfo_resourcebundle_create_proc )
518 PHP_FE( resourcebundle_get, arginfo_resourcebundle_get_proc )
519 PHP_FE( resourcebundle_count, arginfo_resourcebundle_count_proc )
520 PHP_FE( resourcebundle_locales, arginfo_resourcebundle_locales_proc )
521 PHP_FE( resourcebundle_get_error_code, arginfo_resourcebundle_get_error_code_proc )
522 PHP_FE( resourcebundle_get_error_message, arginfo_resourcebundle_get_error_message_proc )
523
524 /* Transliterator functions */
525 PHP_FE( transliterator_create, arginfo_transliterator_create )
526 PHP_FE( transliterator_create_from_rules, arginfo_transliterator_create_from_rules )
527 PHP_FE( transliterator_list_ids, arginfo_transliterator_void )
528 PHP_FE( transliterator_create_inverse, arginfo_transliterator_create_inverse)
529 PHP_FE( transliterator_transliterate, arginfo_transliterator_transliterate )
530 PHP_FE( transliterator_get_error_code, arginfo_transliterator_error )
531 PHP_FE( transliterator_get_error_message, arginfo_transliterator_error )
532
533 /* common functions */
534 PHP_FE( intl_get_error_code, intl_0_args )
535 PHP_FE( intl_get_error_message, intl_0_args )
536 PHP_FE( intl_is_failure, intl_1_arg )
537 PHP_FE( intl_error_name, intl_1_arg )
538
539 PHP_FE_END
540 };
541 /* }}} */
542
543
544 /* {{{ INI Settings */
545 PHP_INI_BEGIN()
546 STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals)
547 STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals)
548
549 PHP_INI_END()
550 /* }}} */
551
552
553 static PHP_GINIT_FUNCTION(intl);
554
555 /* {{{ intl_module_entry */
556 zend_module_entry intl_module_entry = {
557 #if ZEND_MODULE_API_NO >= 20010901
558 STANDARD_MODULE_HEADER,
559 #endif
560 "intl",
561 intl_functions,
562 PHP_MINIT( intl ),
563 PHP_MSHUTDOWN( intl ),
564 PHP_RINIT( intl ),
565 PHP_RSHUTDOWN( intl ),
566 PHP_MINFO( intl ),
567 INTL_MODULE_VERSION,
568 PHP_MODULE_GLOBALS(intl), /* globals descriptor */
569 PHP_GINIT(intl), /* globals ctor */
570 NULL, /* globals dtor */
571 NULL, /* post deactivate */
572 STANDARD_MODULE_PROPERTIES_EX
573 };
574 /* }}} */
575
576 #ifdef COMPILE_DL_INTL
577 ZEND_GET_MODULE( intl )
578 #endif
579
580 /* {{{ intl_init_globals */
PHP_GINIT_FUNCTION(intl)581 static PHP_GINIT_FUNCTION(intl)
582 {
583 memset( intl_globals, 0, sizeof(zend_intl_globals) );
584 }
585 /* }}} */
586
587 /* {{{ PHP_MINIT_FUNCTION
588 */
PHP_MINIT_FUNCTION(intl)589 PHP_MINIT_FUNCTION( intl )
590 {
591 /* For the default locale php.ini setting */
592 REGISTER_INI_ENTRIES();
593
594 REGISTER_LONG_CONSTANT("INTL_MAX_LOCALE_LEN", INTL_MAX_LOCALE_LEN, CONST_CS);
595 REGISTER_STRING_CONSTANT("INTL_ICU_VERSION", U_ICU_VERSION, CONST_PERSISTENT | CONST_CS);
596 #ifdef U_ICU_DATA_VERSION
597 REGISTER_STRING_CONSTANT("INTL_ICU_DATA_VERSION", U_ICU_DATA_VERSION, CONST_PERSISTENT | CONST_CS);
598 #endif
599
600 /* Register 'Collator' PHP class */
601 collator_register_Collator_class( TSRMLS_C );
602
603 /* Expose Collator constants to PHP scripts */
604 collator_register_constants( INIT_FUNC_ARGS_PASSTHRU );
605
606 /* Register 'NumberFormatter' PHP class */
607 formatter_register_class( TSRMLS_C );
608
609 /* Expose NumberFormatter constants to PHP scripts */
610 formatter_register_constants( INIT_FUNC_ARGS_PASSTHRU );
611
612 /* Register 'Normalizer' PHP class */
613 normalizer_register_Normalizer_class( TSRMLS_C );
614
615 /* Expose Normalizer constants to PHP scripts */
616 normalizer_register_constants( INIT_FUNC_ARGS_PASSTHRU );
617
618 /* Register 'Locale' PHP class */
619 locale_register_Locale_class( TSRMLS_C );
620
621 /* Expose Locale constants to PHP scripts */
622 locale_register_constants( INIT_FUNC_ARGS_PASSTHRU );
623
624 msgformat_register_class(TSRMLS_C);
625
626 grapheme_register_constants( INIT_FUNC_ARGS_PASSTHRU );
627
628 /* Register 'DateFormat' PHP class */
629 dateformat_register_IntlDateFormatter_class( TSRMLS_C );
630
631 /* Expose DateFormat constants to PHP scripts */
632 dateformat_register_constants( INIT_FUNC_ARGS_PASSTHRU );
633
634 /* Register 'ResourceBundle' PHP class */
635 resourcebundle_register_class( TSRMLS_C);
636
637 /* Register 'Transliterator' PHP class */
638 transliterator_register_Transliterator_class( TSRMLS_C );
639
640 /* Register Transliterator constants */
641 transliterator_register_constants( INIT_FUNC_ARGS_PASSTHRU );
642
643 /* Expose ICU error codes to PHP scripts. */
644 intl_expose_icu_error_codes( INIT_FUNC_ARGS_PASSTHRU );
645
646 /* Expose IDN constants to PHP scripts. */
647 idn_register_constants(INIT_FUNC_ARGS_PASSTHRU);
648
649 #if U_ICU_VERSION_MAJOR_NUM * 1000 + U_ICU_VERSION_MINOR_NUM >= 4002
650 /* Register 'Spoofchecker' PHP class */
651 spoofchecker_register_Spoofchecker_class( TSRMLS_C );
652
653 /* Expose Spoofchecker constants to PHP scripts */
654 spoofchecker_register_constants( INIT_FUNC_ARGS_PASSTHRU );
655 #endif
656 /* Global error handling. */
657 intl_error_init( NULL TSRMLS_CC );
658
659 /* Set the default_locale value */
660 if( INTL_G(default_locale) == NULL ) {
661 INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
662 }
663
664 return SUCCESS;
665 }
666 /* }}} */
667
668 /* {{{ PHP_MSHUTDOWN_FUNCTION
669 */
PHP_MSHUTDOWN_FUNCTION(intl)670 PHP_MSHUTDOWN_FUNCTION( intl )
671 {
672 /* For the default locale php.ini setting */
673 UNREGISTER_INI_ENTRIES();
674
675 return SUCCESS;
676 }
677 /* }}} */
678
679 /* {{{ PHP_RINIT_FUNCTION
680 */
PHP_RINIT_FUNCTION(intl)681 PHP_RINIT_FUNCTION( intl )
682 {
683 /* Set the default_locale value */
684 if( INTL_G(default_locale) == NULL ) {
685 INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
686 }
687 return SUCCESS;
688 }
689 /* }}} */
690
691 /* {{{ PHP_RSHUTDOWN_FUNCTION
692 */
PHP_RSHUTDOWN_FUNCTION(intl)693 PHP_RSHUTDOWN_FUNCTION( intl )
694 {
695 if(INTL_G(current_collator)) {
696 INTL_G(current_collator) = NULL;
697 }
698 if (INTL_G(grapheme_iterator)) {
699 grapheme_close_global_iterator( TSRMLS_C );
700 INTL_G(grapheme_iterator) = NULL;
701 }
702
703 intl_error_reset( NULL TSRMLS_CC);
704 return SUCCESS;
705 }
706 /* }}} */
707
708 /* {{{ PHP_MINFO_FUNCTION
709 */
PHP_MINFO_FUNCTION(intl)710 PHP_MINFO_FUNCTION( intl )
711 {
712 php_info_print_table_start();
713 php_info_print_table_header( 2, "Internationalization support", "enabled" );
714 php_info_print_table_row( 2, "version", INTL_MODULE_VERSION );
715 php_info_print_table_row( 2, "ICU version", U_ICU_VERSION );
716 #ifdef U_ICU_DATA_VERSION
717 php_info_print_table_row( 2, "ICU Data version", U_ICU_DATA_VERSION );
718 #endif
719 php_info_print_table_end();
720
721 /* For the default locale php.ini setting */
722 DISPLAY_INI_ENTRIES() ;
723 }
724 /* }}} */
725
726 /*
727 * Local variables:
728 * tab-width: 4
729 * c-basic-offset: 4
730 * End:
731 * vim600: noet sw=4 ts=4 fdm=marker
732 * vim<600: noet sw=4 ts=4
733 */
734