PageRenderTime 53ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/ext/intl/php_intl.c

http://github.com/infusion/PHP
C | 664 lines | 457 code | 117 blank | 90 comment | 6 complexity | afaad12ddd691d6f8c863a5eedbf5f69 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause
  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. #ifdef HAVE_CONFIG_H
  20. #include "config.h"
  21. #endif
  22. #include "php_intl.h"
  23. #include "intl_error.h"
  24. #include "collator/collator_class.h"
  25. #include "collator/collator.h"
  26. #include "collator/collator_attr.h"
  27. #include "collator/collator_compare.h"
  28. #include "collator/collator_sort.h"
  29. #include "collator/collator_convert.h"
  30. #include "collator/collator_locale.h"
  31. #include "collator/collator_create.h"
  32. #include "collator/collator_error.h"
  33. #include "formatter/formatter.h"
  34. #include "formatter/formatter_class.h"
  35. #include "formatter/formatter_attr.h"
  36. #include "formatter/formatter_format.h"
  37. #include "formatter/formatter_main.h"
  38. #include "formatter/formatter_parse.h"
  39. #include "msgformat/msgformat.h"
  40. #include "msgformat/msgformat_class.h"
  41. #include "msgformat/msgformat_attr.h"
  42. #include "msgformat/msgformat_format.h"
  43. #include "msgformat/msgformat_parse.h"
  44. #include "normalizer/normalizer.h"
  45. #include "normalizer/normalizer_class.h"
  46. #include "normalizer/normalizer_normalize.h"
  47. #include "locale/locale.h"
  48. #include "locale/locale_class.h"
  49. #include "locale/locale_methods.h"
  50. #include "dateformat/dateformat.h"
  51. #include "dateformat/dateformat_class.h"
  52. #include "dateformat/dateformat_attr.h"
  53. #include "dateformat/dateformat_format.h"
  54. #include "dateformat/dateformat_parse.h"
  55. #include "dateformat/dateformat_data.h"
  56. #include "resourcebundle/resourcebundle_class.h"
  57. #include "idn/idn.h"
  58. #include "msgformat/msgformat.h"
  59. #include "common/common_error.h"
  60. #include <unicode/uloc.h>
  61. #include <ext/standard/info.h>
  62. #include "php_ini.h"
  63. #define INTL_MODULE_VERSION PHP_INTL_VERSION
  64. /*
  65. * locale_get_default has a conflict since ICU also has
  66. * a function with the same name
  67. * in fact ICU appends the version no. to it also
  68. * Hence the following undef for ICU version
  69. * Same true for the locale_set_default function
  70. */
  71. #undef locale_get_default
  72. #undef locale_set_default
  73. ZEND_DECLARE_MODULE_GLOBALS( intl )
  74. /* {{{ Arguments info */
  75. ZEND_BEGIN_ARG_INFO_EX(collator_static_0_args, 0, 0, 0)
  76. ZEND_END_ARG_INFO()
  77. ZEND_BEGIN_ARG_INFO_EX(collator_static_1_arg, 0, 0, 1)
  78. ZEND_ARG_INFO(0, arg1)
  79. ZEND_END_ARG_INFO()
  80. ZEND_BEGIN_ARG_INFO_EX(collator_static_2_args, 0, 0, 2)
  81. ZEND_ARG_INFO(0, arg1)
  82. ZEND_ARG_INFO(0, arg2)
  83. ZEND_END_ARG_INFO()
  84. ZEND_BEGIN_ARG_INFO_EX(collator_0_args, 0, 0, 1)
  85. ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
  86. ZEND_END_ARG_INFO()
  87. ZEND_BEGIN_ARG_INFO_EX(collator_1_arg, 0, 0, 2)
  88. ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
  89. ZEND_ARG_INFO(0, arg1)
  90. ZEND_END_ARG_INFO()
  91. ZEND_BEGIN_ARG_INFO_EX(collator_2_args, 0, 0, 3)
  92. ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
  93. ZEND_ARG_INFO(0, arg1)
  94. ZEND_ARG_INFO(0, arg2)
  95. ZEND_END_ARG_INFO()
  96. ZEND_BEGIN_ARG_INFO_EX(collator_sort_args, 0, 0, 2)
  97. ZEND_ARG_OBJ_INFO(0, object, Collator, 0)
  98. ZEND_ARG_ARRAY_INFO(1, arr, 0)
  99. ZEND_ARG_INFO(0, sort_flags)
  100. ZEND_END_ARG_INFO()
  101. ZEND_BEGIN_ARG_INFO_EX(numfmt_parse_arginfo, 0, 0, 2)
  102. ZEND_ARG_INFO(0, formatter)
  103. ZEND_ARG_INFO(0, string)
  104. ZEND_ARG_INFO(0, type)
  105. ZEND_ARG_INFO(1, position)
  106. ZEND_END_ARG_INFO()
  107. ZEND_BEGIN_ARG_INFO_EX(numfmt_parse_currency_arginfo, 0, 0, 3)
  108. ZEND_ARG_INFO(0, formatter)
  109. ZEND_ARG_INFO(0, string)
  110. ZEND_ARG_INFO(1, currency)
  111. ZEND_ARG_INFO(1, position)
  112. ZEND_END_ARG_INFO()
  113. ZEND_BEGIN_ARG_INFO_EX(locale_0_args, 0, 0, 0)
  114. ZEND_END_ARG_INFO()
  115. ZEND_BEGIN_ARG_INFO_EX(locale_1_arg, 0, 0, 1)
  116. ZEND_ARG_INFO(0, arg1)
  117. ZEND_END_ARG_INFO()
  118. ZEND_BEGIN_ARG_INFO_EX(locale_2_args, 0, 0, 2)
  119. ZEND_ARG_INFO(0, arg1)
  120. ZEND_ARG_INFO(0, arg2)
  121. ZEND_END_ARG_INFO()
  122. ZEND_BEGIN_ARG_INFO_EX(locale_3_args, 0, 0, 3)
  123. ZEND_ARG_INFO(0, arg1)
  124. ZEND_ARG_INFO(0, arg2)
  125. ZEND_ARG_INFO(0, arg3)
  126. ZEND_END_ARG_INFO()
  127. ZEND_BEGIN_ARG_INFO_EX(locale_4_args, 0, 0, 4)
  128. ZEND_ARG_INFO(0, arg1)
  129. ZEND_ARG_INFO(0, arg2)
  130. ZEND_ARG_INFO(0, arg3)
  131. ZEND_ARG_INFO(0, arg4)
  132. ZEND_END_ARG_INFO()
  133. #define intl_0_args collator_static_0_args
  134. #define intl_1_arg collator_static_1_arg
  135. ZEND_BEGIN_ARG_INFO_EX(normalizer_args, 0, 0, 1)
  136. ZEND_ARG_INFO(0, input)
  137. ZEND_ARG_INFO(0, form)
  138. ZEND_END_ARG_INFO()
  139. ZEND_BEGIN_ARG_INFO_EX(grapheme_1_arg, 0, 0, 1)
  140. ZEND_ARG_INFO(0, string)
  141. ZEND_END_ARG_INFO()
  142. ZEND_BEGIN_ARG_INFO_EX(grapheme_search_args, 0, 0, 2)
  143. ZEND_ARG_INFO(0, haystack)
  144. ZEND_ARG_INFO(0, needle)
  145. ZEND_ARG_INFO(0, offset)
  146. ZEND_END_ARG_INFO()
  147. ZEND_BEGIN_ARG_INFO_EX(grapheme_substr_args, 0, 0, 2)
  148. ZEND_ARG_INFO(0, string)
  149. ZEND_ARG_INFO(0, start)
  150. ZEND_ARG_INFO(0, length)
  151. ZEND_END_ARG_INFO()
  152. ZEND_BEGIN_ARG_INFO_EX(grapheme_strstr_args, 0, 0, 2)
  153. ZEND_ARG_INFO(0, haystack)
  154. ZEND_ARG_INFO(0, needle)
  155. ZEND_ARG_INFO(0, before_needle)
  156. ZEND_END_ARG_INFO()
  157. ZEND_BEGIN_ARG_INFO_EX(grapheme_extract_args, 0, 0, 2)
  158. ZEND_ARG_INFO(0, arg1)
  159. ZEND_ARG_INFO(0, arg2)
  160. ZEND_ARG_INFO(0, arg3)
  161. ZEND_ARG_INFO(0, arg4)
  162. ZEND_ARG_INFO(1, arg5) /* 1 = pass by reference */
  163. ZEND_END_ARG_INFO()
  164. ZEND_BEGIN_ARG_INFO_EX(datefmt_parse_args, 0, 0, 2)
  165. ZEND_ARG_INFO(0, formatter)
  166. ZEND_ARG_INFO(0, string)
  167. ZEND_ARG_INFO(1, position)
  168. ZEND_END_ARG_INFO()
  169. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_create, 0, 0, 2)
  170. ZEND_ARG_INFO(0, locale)
  171. ZEND_ARG_INFO(0, style)
  172. ZEND_ARG_INFO(0, pattern)
  173. ZEND_END_ARG_INFO()
  174. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_error_code, 0, 0, 1)
  175. ZEND_ARG_INFO(0, nf)
  176. ZEND_END_ARG_INFO()
  177. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format, 0, 0, 2)
  178. ZEND_ARG_INFO(0, nf)
  179. ZEND_ARG_INFO(0, num)
  180. ZEND_ARG_INFO(0, type)
  181. ZEND_END_ARG_INFO()
  182. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_format_currency, 0, 0, 3)
  183. ZEND_ARG_INFO(0, nf)
  184. ZEND_ARG_INFO(0, num)
  185. ZEND_ARG_INFO(0, currency)
  186. ZEND_END_ARG_INFO()
  187. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_attribute, 0, 0, 2)
  188. ZEND_ARG_INFO(0, nf)
  189. ZEND_ARG_INFO(0, attr)
  190. ZEND_END_ARG_INFO()
  191. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_attribute, 0, 0, 3)
  192. ZEND_ARG_INFO(0, nf)
  193. ZEND_ARG_INFO(0, attr)
  194. ZEND_ARG_INFO(0, value)
  195. ZEND_END_ARG_INFO()
  196. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_symbol, 0, 0, 3)
  197. ZEND_ARG_INFO(0, nf)
  198. ZEND_ARG_INFO(0, attr)
  199. ZEND_ARG_INFO(0, symbol)
  200. ZEND_END_ARG_INFO()
  201. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_set_pattern, 0, 0, 2)
  202. ZEND_ARG_INFO(0, nf)
  203. ZEND_ARG_INFO(0, pattern)
  204. ZEND_END_ARG_INFO()
  205. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_get_locale, 0, 0, 1)
  206. ZEND_ARG_INFO(0, nf)
  207. ZEND_ARG_INFO(0, type)
  208. ZEND_END_ARG_INFO()
  209. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_create, 0, 0, 2)
  210. ZEND_ARG_INFO(0, locale)
  211. ZEND_ARG_INFO(0, pattern)
  212. ZEND_END_ARG_INFO()
  213. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_error_code, 0, 0, 1)
  214. ZEND_ARG_INFO(0, nf)
  215. ZEND_END_ARG_INFO()
  216. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_error_message, 0, 0, 1)
  217. ZEND_ARG_INFO(0, coll)
  218. ZEND_END_ARG_INFO()
  219. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_format, 0, 0, 2)
  220. ZEND_ARG_INFO(0, nf)
  221. ZEND_ARG_INFO(0, args)
  222. ZEND_END_ARG_INFO()
  223. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_format_message, 0, 0, 3)
  224. ZEND_ARG_INFO(0, locale)
  225. ZEND_ARG_INFO(0, pattern)
  226. ZEND_ARG_INFO(0, args)
  227. ZEND_END_ARG_INFO()
  228. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_parse, 0, 0, 2)
  229. ZEND_ARG_INFO(0, nf)
  230. ZEND_ARG_INFO(0, source)
  231. ZEND_END_ARG_INFO()
  232. ZEND_BEGIN_ARG_INFO_EX(arginfo_numfmt_parse_message, 0, 0, 3)
  233. ZEND_ARG_INFO(0, locale)
  234. ZEND_ARG_INFO(0, pattern)
  235. ZEND_ARG_INFO(0, source)
  236. ZEND_END_ARG_INFO()
  237. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_set_pattern, 0, 0, 2)
  238. ZEND_ARG_INFO(0, mf)
  239. ZEND_ARG_INFO(0, pattern)
  240. ZEND_END_ARG_INFO()
  241. ZEND_BEGIN_ARG_INFO_EX(arginfo_msgfmt_get_locale, 0, 0, 1)
  242. ZEND_ARG_INFO(0, mf)
  243. ZEND_END_ARG_INFO()
  244. ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_pattern, 0, 0, 2)
  245. ZEND_ARG_INFO(0, mf)
  246. ZEND_ARG_INFO(0, pattern)
  247. ZEND_END_ARG_INFO()
  248. ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_set_calendar, 0, 0, 2)
  249. ZEND_ARG_INFO(0, mf)
  250. ZEND_ARG_INFO(0, calendar)
  251. ZEND_END_ARG_INFO()
  252. ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_format, 0, 0, 0)
  253. ZEND_ARG_INFO(0, args)
  254. ZEND_ARG_INFO(0, array)
  255. ZEND_END_ARG_INFO()
  256. ZEND_BEGIN_ARG_INFO_EX(arginfo_datefmt_create, 0, 0, 3)
  257. ZEND_ARG_INFO(0, locale)
  258. ZEND_ARG_INFO(0, date_type)
  259. ZEND_ARG_INFO(0, time_type)
  260. ZEND_ARG_INFO(0, timezone_str)
  261. ZEND_ARG_INFO(0, calendar)
  262. ZEND_ARG_INFO(0, pattern)
  263. ZEND_END_ARG_INFO()
  264. ZEND_BEGIN_ARG_INFO_EX(arginfo_idn_to_ascii, 0, 0, 1)
  265. ZEND_ARG_INFO(0, domain)
  266. ZEND_ARG_INFO(0, option)
  267. ZEND_ARG_INFO(0, status)
  268. ZEND_END_ARG_INFO()
  269. ZEND_BEGIN_ARG_INFO_EX(arginfo_idn_to_utf8, 0, 0, 1)
  270. ZEND_ARG_INFO(0, domain)
  271. ZEND_ARG_INFO(0, option)
  272. ZEND_ARG_INFO(0, status)
  273. ZEND_END_ARG_INFO()
  274. ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_create_proc, 0, 0, 2 )
  275. ZEND_ARG_INFO( 0, locale )
  276. ZEND_ARG_INFO( 0, bundlename )
  277. ZEND_ARG_INFO( 0, fallback )
  278. ZEND_END_ARG_INFO()
  279. ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_proc, 0, 0, 2 )
  280. ZEND_ARG_INFO( 0, bundle )
  281. ZEND_ARG_INFO( 0, index )
  282. ZEND_ARG_INFO( 0, fallback )
  283. ZEND_END_ARG_INFO()
  284. ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_count_proc, 0, 0, 1 )
  285. ZEND_ARG_INFO( 0, bundle )
  286. ZEND_END_ARG_INFO()
  287. ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_locales_proc, 0, 0, 1 )
  288. ZEND_ARG_INFO( 0, bundlename )
  289. ZEND_END_ARG_INFO()
  290. ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_code_proc, 0, 0, 1 )
  291. ZEND_ARG_INFO( 0, bundle )
  292. ZEND_END_ARG_INFO()
  293. ZEND_BEGIN_ARG_INFO_EX( arginfo_resourcebundle_get_error_message_proc, 0, 0, 1 )
  294. ZEND_ARG_INFO( 0, bundle )
  295. ZEND_END_ARG_INFO()
  296. /* }}} */
  297. /* {{{ intl_functions
  298. *
  299. * Every user visible function must have an entry in intl_functions[].
  300. */
  301. zend_function_entry intl_functions[] = {
  302. /* collator functions */
  303. PHP_FE( collator_create, collator_static_1_arg )
  304. PHP_FE( collator_compare, collator_2_args )
  305. PHP_FE( collator_get_attribute, collator_1_arg )
  306. PHP_FE( collator_set_attribute, collator_2_args )
  307. PHP_FE( collator_get_strength, collator_0_args )
  308. PHP_FE( collator_set_strength, collator_1_arg )
  309. PHP_FE( collator_sort, collator_sort_args )
  310. PHP_FE( collator_sort_with_sort_keys, collator_sort_args )
  311. PHP_FE( collator_asort, collator_sort_args )
  312. PHP_FE( collator_get_locale, collator_1_arg )
  313. PHP_FE( collator_get_error_code, collator_0_args )
  314. PHP_FE( collator_get_error_message, collator_0_args )
  315. PHP_FE( collator_get_sort_key, collator_2_args )
  316. /* formatter functions */
  317. PHP_FE( numfmt_create, arginfo_numfmt_create )
  318. PHP_FE( numfmt_format, arginfo_numfmt_format )
  319. PHP_FE( numfmt_parse, numfmt_parse_arginfo )
  320. PHP_FE( numfmt_format_currency, arginfo_numfmt_format_currency )
  321. PHP_FE( numfmt_parse_currency, numfmt_parse_currency_arginfo )
  322. PHP_FE( numfmt_set_attribute, arginfo_numfmt_set_attribute )
  323. PHP_FE( numfmt_get_attribute, arginfo_numfmt_get_attribute )
  324. PHP_FE( numfmt_set_text_attribute, arginfo_numfmt_set_attribute )
  325. PHP_FE( numfmt_get_text_attribute, arginfo_numfmt_get_attribute )
  326. PHP_FE( numfmt_set_symbol, arginfo_numfmt_set_symbol )
  327. PHP_FE( numfmt_get_symbol, arginfo_numfmt_get_attribute )
  328. PHP_FE( numfmt_set_pattern, arginfo_numfmt_set_pattern )
  329. PHP_FE( numfmt_get_pattern, arginfo_numfmt_get_error_code )
  330. PHP_FE( numfmt_get_locale, arginfo_numfmt_get_locale )
  331. PHP_FE( numfmt_get_error_code, arginfo_numfmt_get_error_code )
  332. PHP_FE( numfmt_get_error_message, arginfo_numfmt_get_error_code )
  333. /* normalizer functions */
  334. PHP_FE( normalizer_normalize, normalizer_args )
  335. PHP_FE( normalizer_is_normalized, normalizer_args )
  336. /* Locale functions */
  337. PHP_NAMED_FE( locale_get_default, zif_locale_get_default, locale_0_args )
  338. PHP_NAMED_FE( locale_set_default, zif_locale_set_default, locale_1_arg )
  339. PHP_FE( locale_get_primary_language, locale_1_arg )
  340. PHP_FE( locale_get_script, locale_1_arg )
  341. PHP_FE( locale_get_region, locale_1_arg )
  342. PHP_FE( locale_get_keywords, locale_1_arg )
  343. PHP_FE( locale_get_display_script, locale_2_args )
  344. PHP_FE( locale_get_display_region, locale_2_args )
  345. PHP_FE( locale_get_display_name, locale_2_args )
  346. PHP_FE( locale_get_display_language, locale_2_args)
  347. PHP_FE( locale_get_display_variant, locale_2_args )
  348. PHP_FE( locale_compose, locale_1_arg )
  349. PHP_FE( locale_parse, locale_1_arg )
  350. PHP_FE( locale_get_all_variants, locale_1_arg )
  351. PHP_FE( locale_filter_matches, locale_3_args )
  352. PHP_FE( locale_canonicalize, locale_1_arg )
  353. PHP_FE( locale_lookup, locale_4_args )
  354. PHP_FE( locale_accept_from_http, locale_1_arg )
  355. /* MessageFormatter functions */
  356. PHP_FE( msgfmt_create, arginfo_msgfmt_create )
  357. PHP_FE( msgfmt_format, arginfo_msgfmt_format )
  358. PHP_FE( msgfmt_format_message, arginfo_msgfmt_format_message )
  359. PHP_FE( msgfmt_parse, arginfo_msgfmt_parse )
  360. PHP_FE( msgfmt_parse_message, arginfo_numfmt_parse_message )
  361. PHP_FE( msgfmt_set_pattern, arginfo_msgfmt_set_pattern )
  362. PHP_FE( msgfmt_get_pattern, arginfo_msgfmt_get_locale )
  363. PHP_FE( msgfmt_get_locale, arginfo_msgfmt_get_locale )
  364. PHP_FE( msgfmt_get_error_code, arginfo_msgfmt_get_error_code )
  365. PHP_FE( msgfmt_get_error_message, arginfo_msgfmt_get_error_message )
  366. /* IntlDateFormatter functions */
  367. PHP_FE( datefmt_create, arginfo_datefmt_create )
  368. PHP_FE( datefmt_get_datetype, arginfo_msgfmt_get_locale )
  369. PHP_FE( datefmt_get_timetype, arginfo_msgfmt_get_locale )
  370. PHP_FE( datefmt_get_calendar, arginfo_msgfmt_get_locale )
  371. PHP_FE( datefmt_set_calendar, arginfo_datefmt_set_calendar )
  372. PHP_FE( datefmt_get_locale, arginfo_msgfmt_get_locale )
  373. PHP_FE( datefmt_get_timezone_id, arginfo_msgfmt_get_locale )
  374. PHP_FE( datefmt_set_timezone_id, arginfo_msgfmt_get_locale )
  375. PHP_FE( datefmt_get_pattern, arginfo_msgfmt_get_locale )
  376. PHP_FE( datefmt_set_pattern, arginfo_datefmt_set_pattern )
  377. PHP_FE( datefmt_is_lenient, arginfo_msgfmt_get_locale )
  378. PHP_FE( datefmt_set_lenient, arginfo_msgfmt_get_locale )
  379. PHP_FE( datefmt_format, arginfo_datefmt_format )
  380. PHP_FE( datefmt_parse, datefmt_parse_args )
  381. PHP_FE( datefmt_localtime , datefmt_parse_args )
  382. PHP_FE( datefmt_get_error_code, arginfo_msgfmt_get_error_code )
  383. PHP_FE( datefmt_get_error_message, arginfo_msgfmt_get_error_message )
  384. /* grapheme functions */
  385. PHP_FE( grapheme_strlen, grapheme_1_arg )
  386. PHP_FE( grapheme_strpos, grapheme_search_args )
  387. PHP_FE( grapheme_stripos, grapheme_search_args )
  388. PHP_FE( grapheme_strrpos, grapheme_search_args )
  389. PHP_FE( grapheme_strripos, grapheme_search_args )
  390. PHP_FE( grapheme_substr, grapheme_substr_args )
  391. PHP_FE( grapheme_strstr, grapheme_strstr_args )
  392. PHP_FE( grapheme_stristr, grapheme_strstr_args )
  393. PHP_FE( grapheme_extract, grapheme_extract_args )
  394. /* IDN functions */
  395. PHP_FE( idn_to_ascii, arginfo_idn_to_ascii)
  396. PHP_FE( idn_to_utf8, arginfo_idn_to_ascii)
  397. /* ResourceBundle functions */
  398. PHP_FE( resourcebundle_create, arginfo_resourcebundle_create_proc )
  399. PHP_FE( resourcebundle_get, arginfo_resourcebundle_get_proc )
  400. PHP_FE( resourcebundle_count, arginfo_resourcebundle_count_proc )
  401. PHP_FE( resourcebundle_locales, arginfo_resourcebundle_locales_proc )
  402. PHP_FE( resourcebundle_get_error_code, arginfo_resourcebundle_get_error_code_proc )
  403. PHP_FE( resourcebundle_get_error_message, arginfo_resourcebundle_get_error_message_proc )
  404. /* common functions */
  405. PHP_FE( intl_get_error_code, intl_0_args )
  406. PHP_FE( intl_get_error_message, intl_0_args )
  407. PHP_FE( intl_is_failure, intl_1_arg )
  408. PHP_FE( intl_error_name, intl_1_arg )
  409. { NULL, NULL, NULL }
  410. };
  411. /* }}} */
  412. /* {{{ INI Settings */
  413. PHP_INI_BEGIN()
  414. STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals)
  415. STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals)
  416. PHP_INI_END()
  417. /* }}} */
  418. static PHP_GINIT_FUNCTION(intl);
  419. /* {{{ intl_module_entry */
  420. zend_module_entry intl_module_entry = {
  421. #if ZEND_MODULE_API_NO >= 20010901
  422. STANDARD_MODULE_HEADER,
  423. #endif
  424. "intl",
  425. intl_functions,
  426. PHP_MINIT( intl ),
  427. PHP_MSHUTDOWN( intl ),
  428. PHP_RINIT( intl ),
  429. PHP_RSHUTDOWN( intl ),
  430. PHP_MINFO( intl ),
  431. INTL_MODULE_VERSION,
  432. PHP_MODULE_GLOBALS(intl), /* globals descriptor */
  433. PHP_GINIT(intl), /* globals ctor */
  434. NULL, /* globals dtor */
  435. NULL, /* post deactivate */
  436. STANDARD_MODULE_PROPERTIES_EX
  437. };
  438. /* }}} */
  439. #ifdef COMPILE_DL_INTL
  440. ZEND_GET_MODULE( intl )
  441. #endif
  442. /* {{{ intl_init_globals */
  443. static PHP_GINIT_FUNCTION(intl)
  444. {
  445. memset( intl_globals, 0, sizeof(zend_intl_globals) );
  446. }
  447. /* }}} */
  448. /* {{{ PHP_MINIT_FUNCTION
  449. */
  450. PHP_MINIT_FUNCTION( intl )
  451. {
  452. /* For the default locale php.ini setting */
  453. REGISTER_INI_ENTRIES();
  454. REGISTER_LONG_CONSTANT("INTL_MAX_LOCALE_LEN", INTL_MAX_LOCALE_LEN, CONST_CS);
  455. /* Register 'Collator' PHP class */
  456. collator_register_Collator_class( TSRMLS_C );
  457. /* Expose Collator constants to PHP scripts */
  458. collator_register_constants( INIT_FUNC_ARGS_PASSTHRU );
  459. /* Register 'NumberFormatter' PHP class */
  460. formatter_register_class( TSRMLS_C );
  461. /* Expose NumberFormatter constants to PHP scripts */
  462. formatter_register_constants( INIT_FUNC_ARGS_PASSTHRU );
  463. /* Register 'Normalizer' PHP class */
  464. normalizer_register_Normalizer_class( TSRMLS_C );
  465. /* Expose Normalizer constants to PHP scripts */
  466. normalizer_register_constants( INIT_FUNC_ARGS_PASSTHRU );
  467. /* Register 'Locale' PHP class */
  468. locale_register_Locale_class( TSRMLS_C );
  469. /* Expose Locale constants to PHP scripts */
  470. locale_register_constants( INIT_FUNC_ARGS_PASSTHRU );
  471. msgformat_register_class(TSRMLS_C);
  472. grapheme_register_constants( INIT_FUNC_ARGS_PASSTHRU );
  473. /* Register 'DateFormat' PHP class */
  474. dateformat_register_IntlDateFormatter_class( TSRMLS_C );
  475. /* Expose DateFormat constants to PHP scripts */
  476. dateformat_register_constants( INIT_FUNC_ARGS_PASSTHRU );
  477. /* Register 'ResourceBundle' PHP class */
  478. resourcebundle_register_class( TSRMLS_C);
  479. /* Expose ICU error codes to PHP scripts. */
  480. intl_expose_icu_error_codes( INIT_FUNC_ARGS_PASSTHRU );
  481. /* Expose IDN constants to PHP scripts. */
  482. idn_register_constants(INIT_FUNC_ARGS_PASSTHRU);
  483. /* Global error handling. */
  484. intl_error_init( NULL TSRMLS_CC );
  485. /* Set the default_locale value */
  486. if( INTL_G(default_locale) == NULL ) {
  487. INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
  488. }
  489. return SUCCESS;
  490. }
  491. /* }}} */
  492. /* {{{ PHP_MSHUTDOWN_FUNCTION
  493. */
  494. PHP_MSHUTDOWN_FUNCTION( intl )
  495. {
  496. /* For the default locale php.ini setting */
  497. UNREGISTER_INI_ENTRIES();
  498. return SUCCESS;
  499. }
  500. /* }}} */
  501. /* {{{ PHP_RINIT_FUNCTION
  502. */
  503. PHP_RINIT_FUNCTION( intl )
  504. {
  505. /* Set the default_locale value */
  506. if( INTL_G(default_locale) == NULL ) {
  507. INTL_G(default_locale) = pestrdup(uloc_getDefault(), 1) ;
  508. }
  509. return SUCCESS;
  510. }
  511. /* }}} */
  512. /* {{{ PHP_RSHUTDOWN_FUNCTION
  513. */
  514. PHP_RSHUTDOWN_FUNCTION( intl )
  515. {
  516. if(INTL_G(current_collator)) {
  517. INTL_G(current_collator) = NULL;
  518. }
  519. if (INTL_G(grapheme_iterator)) {
  520. grapheme_close_global_iterator( TSRMLS_C );
  521. INTL_G(grapheme_iterator) = NULL;
  522. }
  523. intl_error_reset( NULL TSRMLS_CC);
  524. return SUCCESS;
  525. }
  526. /* }}} */
  527. /* {{{ PHP_MINFO_FUNCTION
  528. */
  529. PHP_MINFO_FUNCTION( intl )
  530. {
  531. php_info_print_table_start();
  532. php_info_print_table_header( 2, "Internationalization support", "enabled" );
  533. php_info_print_table_row( 2, "version", INTL_MODULE_VERSION );
  534. php_info_print_table_row( 2, "ICU version", U_ICU_VERSION );
  535. php_info_print_table_end();
  536. /* For the default locale php.ini setting */
  537. DISPLAY_INI_ENTRIES() ;
  538. }
  539. /* }}} */
  540. /*
  541. * Local variables:
  542. * tab-width: 4
  543. * c-basic-offset: 4
  544. * End:
  545. * vim600: noet sw=4 ts=4 fdm=marker
  546. * vim<600: noet sw=4 ts=4
  547. */