php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
php_intl.c
Go to the documentation of this file.
1/*
2 +----------------------------------------------------------------------+
3 | This source file is subject to version 3.01 of the PHP license, |
4 | that is bundled with this package in the file LICENSE, and is |
5 | available through the world-wide-web at the following url: |
6 | https://www.php.net/license/3_01.txt |
7 | If you did not receive a copy of the PHP license and are unable to |
8 | obtain it through the world-wide-web, please send a note to |
9 | license@php.net so we can mail you a copy immediately. |
10 +----------------------------------------------------------------------+
11 | Authors: Vadim Savchuk <vsavchuk@productengine.com> |
12 | Dmitry Lakhtyuk <dlakhtyuk@productengine.com> |
13 | Stanislav Malyshev <stas@zend.com> |
14 | Kirti Velankar <kirtig@yahoo-inc.com> |
15 +----------------------------------------------------------------------+
16 */
17
18#ifdef HAVE_CONFIG_H
19#include <config.h>
20#endif
21
22
23#include "php_intl.h"
24#include "intl_error.h"
26#include "collator/collator.h"
29
30#include "converter/converter.h"
31
34
35#include "grapheme/grapheme.h"
36
38
40
41#include "locale/locale.h"
42#include "locale/locale_class.h"
43
48
50
53
55
57
60
61#include <unicode/uidna.h>
62#include "idn/idn.h"
63#include "uchar/uchar.h"
64
66
67#include "common/common_enum.h"
68
69#include <unicode/uloc.h>
70#include <unicode/uclean.h>
71#include <ext/standard/info.h>
72
73#include "php_ini.h"
74
75#include "zend_attributes.h"
76
77#include "php_intl_arginfo.h"
78
79/*
80 * locale_get_default has a conflict since ICU also has
81 * a function with the same name
82 * in fact ICU appends the version no. to it also
83 * Hence the following undef for ICU version
84 * Same true for the locale_set_default function
85*/
86#undef locale_get_default
87#undef locale_set_default
88
90
91const char *intl_locale_get_default( void )
92{
93 if( INTL_G(default_locale) == NULL ) {
94 return uloc_getDefault();
95 }
96 return INTL_G(default_locale);
97}
98
99/* {{{ INI Settings */
101 STD_PHP_INI_ENTRY(LOCALE_INI_NAME, NULL, PHP_INI_ALL, OnUpdateStringUnempty, default_locale, zend_intl_globals, intl_globals)
102 STD_PHP_INI_ENTRY("intl.error_level", "0", PHP_INI_ALL, OnUpdateLong, error_level, zend_intl_globals, intl_globals)
103 STD_PHP_INI_BOOLEAN("intl.use_exceptions", "0", PHP_INI_ALL, OnUpdateBool, use_exceptions, zend_intl_globals, intl_globals)
105/* }}} */
106
107static PHP_GINIT_FUNCTION(intl);
108
109/* {{{ intl_module_entry */
112 "intl",
113 ext_functions,
114 PHP_MINIT( intl ),
115 PHP_MSHUTDOWN( intl ),
116 PHP_RINIT( intl ),
117 PHP_RSHUTDOWN( intl ),
118 PHP_MINFO( intl ),
120 PHP_MODULE_GLOBALS(intl), /* globals descriptor */
121 PHP_GINIT(intl), /* globals ctor */
122 NULL, /* globals dtor */
123 NULL, /* post deactivate */
125};
126/* }}} */
127
128#ifdef COMPILE_DL_INTL
129#ifdef ZTS
131#endif
132ZEND_GET_MODULE( intl )
133#endif
134
135/* {{{ intl_init_globals */
136static PHP_GINIT_FUNCTION(intl)
137{
138#if defined(COMPILE_DL_INTL) && defined(ZTS)
140#endif
141 memset( intl_globals, 0, sizeof(zend_intl_globals) );
142}
143/* }}} */
144
145/* {{{ PHP_MINIT_FUNCTION */
147{
148 /* For the default locale php.ini setting */
150
151 register_php_intl_symbols(module_number);
152
153 /* Register collator symbols and classes */
155
156 /* Register 'NumberFormatter' PHP class */
158
159 /* Register 'Normalizer' PHP class */
161
162 /* Register 'Locale' PHP class */
164
166
167 /* Register 'DateFormat' PHP class */
169
170 /* Register 'IntlDateTimeFormatter' PHP class */
172
173 /* Register 'ResourceBundle' PHP class */
175
176 /* Register 'Transliterator' PHP class */
178
179 /* Register 'IntlTimeZone' PHP class */
181
182 /* Register 'IntlCalendar' PHP class */
184
185 /* Register 'Spoofchecker' PHP class */
187
188 /* Register 'IntlException' PHP class */
189 IntlException_ce_ptr = register_class_IntlException(zend_ce_exception);
190 IntlException_ce_ptr->create_object = zend_ce_exception->create_object;
191
192 /* Register common symbols and classes */
193 intl_register_common_symbols(module_number);
194
195 /* Register 'BreakIterator' class */
197
198 /* Register 'IntlPartsIterator' class */
200
201 /* Global error handling. */
203
204 /* 'Converter' class for codepage conversions */
206
207 /* IntlChar class */
209
210 return SUCCESS;
211}
212/* }}} */
213
214#define EXPLICIT_CLEANUP_ENV_VAR "INTL_EXPLICIT_CLEANUP"
215
216/* {{{ PHP_MSHUTDOWN_FUNCTION */
218{
219 const char *cleanup;
220 /* For the default locale php.ini setting */
222
224 if (cleanup != NULL && !(cleanup[0] == '0' && cleanup[1] == '\0')) {
225 u_cleanup();
226 }
227
228 return SUCCESS;
229}
230/* }}} */
231
232/* {{{ PHP_RINIT_FUNCTION */
234{
235 return SUCCESS;
236}
237/* }}} */
238
239/* {{{ PHP_RSHUTDOWN_FUNCTION */
251/* }}} */
252
253/* {{{ PHP_MINFO_FUNCTION */
255{
256#if !UCONFIG_NO_FORMATTING
257 UErrorCode status = U_ZERO_ERROR;
258 const char *tzdata_ver = NULL;
259#endif
260
262 php_info_print_table_row( 2, "Internationalization support", "enabled" );
263 php_info_print_table_row( 2, "ICU version", U_ICU_VERSION );
264#ifdef U_ICU_DATA_VERSION
265 php_info_print_table_row( 2, "ICU Data version", U_ICU_DATA_VERSION );
266#endif
267#if !UCONFIG_NO_FORMATTING
268 tzdata_ver = ucal_getTZDataVersion(&status);
269 if (U_ZERO_ERROR == status) {
270 php_info_print_table_row( 2, "ICU TZData version", tzdata_ver);
271 }
272#endif
273 php_info_print_table_row( 2, "ICU Unicode version", U_UNICODE_VERSION );
275
276 /* For the default locale php.ini setting */
278}
279/* }}} */
getenv(?string $name=null, bool $local_only=false)
void breakiterator_register_BreakIterator_class(void)
U_CFUNC void breakiterator_register_IntlPartsIterator_class(void)
void calendar_register_IntlCalendar_class(void)
void collator_register_Collator_symbols(int module_number)
const U_ZERO_ERROR
U_CFUNC void intl_register_common_symbols(int module_number)
int php_converter_minit(INIT_FUNC_ARGS)
Definition converter.c:966
void dateformat_register_IntlDateFormatter_class(void)
void dateformat_register_IntlDatePatternGenerator_class(void)
DNS_STATUS status
Definition dns_win32.c:49
memset(ptr, 0, type->size)
void formatter_register_class(void)
#define NULL
Definition gdcache.h:45
void grapheme_close_global_iterator(void)
#define SUCCESS
Definition hash_sha3.c:261
zend_class_entry * IntlException_ce_ptr
Definition intl_error.c:30
void intl_error_init(intl_error *err)
Definition intl_error.c:66
void intl_error_reset(intl_error *err)
Definition intl_error.c:78
#define LOCALE_INI_NAME
Definition locale.h:30
void locale_register_Locale_class(void)
void msgformat_register_class(void)
void normalizer_register_Normalizer_class(void)
php_info_print_table_start()
Definition info.c:1064
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
Definition info.c:1074
#define PHP_GINIT
Definition php.h:397
#define PHP_MSHUTDOWN_FUNCTION
Definition php.h:401
#define PHP_MINFO
Definition php.h:396
#define PHP_MINIT_FUNCTION
Definition php.h:400
#define PHP_RINIT
Definition php.h:394
#define PHP_MSHUTDOWN
Definition php.h:393
#define PHP_MINFO_FUNCTION
Definition php.h:404
#define PHP_GINIT_FUNCTION
Definition php.h:405
#define PHP_RSHUTDOWN
Definition php.h:395
#define PHP_RINIT_FUNCTION
Definition php.h:402
#define PHP_RSHUTDOWN_FUNCTION
Definition php.h:403
#define PHP_MINIT
Definition php.h:392
#define PHP_MODULE_GLOBALS
Definition php.h:408
#define PHP_INI_ALL
Definition php_ini.h:45
#define PHP_INI_BEGIN
Definition php_ini.h:52
#define STD_PHP_INI_ENTRY
Definition php_ini.h:64
#define STD_PHP_INI_BOOLEAN
Definition php_ini.h:66
#define PHP_INI_END
Definition php_ini.h:53
zend_module_entry intl_module_entry
Definition php_intl.c:110
const char * intl_locale_get_default(void)
Definition php_intl.c:91
#define EXPLICIT_CLEANUP_ENV_VAR
Definition php_intl.c:214
bool use_exceptions
Definition php_intl.h:53
zend_long error_level
Definition php_intl.h:52
char * default_locale
Definition php_intl.h:48
UBreakIterator * grapheme_iterator
Definition php_intl.h:50
#define INTL_G(v)
Definition php_intl.h:62
struct UCollator * current_collator
Definition php_intl.h:47
#define PHP_INTL_VERSION
Definition php_intl.h:72
void resourcebundle_register_class(void)
void spoofchecker_register_Spoofchecker_class(void)
void timezone_register_IntlTimeZone_class(void)
void transliterator_register_Transliterator_class(void)
int php_uchar_minit(INIT_FUNC_ARGS)
Definition uchar.c:625
#define ZEND_TSRMLS_CACHE_UPDATE()
Definition zend.h:69
#define ZEND_TSRMLS_CACHE_DEFINE()
Definition zend.h:68
#define ZEND_DECLARE_MODULE_GLOBALS(module_name)
Definition zend_API.h:268
#define ZEND_GET_MODULE(name)
Definition zend_API.h:241
ZEND_API zend_class_entry * zend_ce_exception
#define UNREGISTER_INI_ENTRIES()
Definition zend_ini.h:204
#define REGISTER_INI_ENTRIES()
Definition zend_ini.h:203
#define DISPLAY_INI_ENTRIES()
Definition zend_ini.h:205
#define STANDARD_MODULE_HEADER
#define INIT_FUNC_ARGS_PASSTHRU
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES_EX