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: Ed Batutis <ed@batutis.com> |
12 +----------------------------------------------------------------------+
13 */
14
15 #ifdef HAVE_CONFIG_H
16 #include "config.h"
17 #endif
18
19 #include "normalizer_class.h"
20 #include "normalizer.h"
21
22 #include <unicode/utypes.h>
23 #include <unicode/unorm.h>
24 #include <unicode/ustring.h>
25
26 /* {{{ normalizer_register_constants
27 * Register constants common for the both (OO and procedural)
28 * APIs.
29 */
normalizer_register_constants(INIT_FUNC_ARGS)30 void normalizer_register_constants( INIT_FUNC_ARGS )
31 {
32 if( !Normalizer_ce_ptr )
33 {
34 zend_error( E_ERROR, "Normalizer class not defined" );
35 return;
36 }
37
38 #define NORMALIZER_EXPOSE_CONST(x) REGISTER_LONG_CONSTANT(#x, x, CONST_PERSISTENT | CONST_CS)
39 #define NORMALIZER_EXPOSE_CLASS_CONST(x) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( #x ) - 1, NORMALIZER_##x );
40 #define NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST(name, value) zend_declare_class_constant_long( Normalizer_ce_ptr, ZEND_STRS( name ) - 1, value );
41
42 /* Normalization form constants */
43 NORMALIZER_EXPOSE_CLASS_CONST( FORM_D );
44 NORMALIZER_EXPOSE_CLASS_CONST( NFD );
45 NORMALIZER_EXPOSE_CLASS_CONST( FORM_KD );
46 NORMALIZER_EXPOSE_CLASS_CONST( NFKD );
47 NORMALIZER_EXPOSE_CLASS_CONST( FORM_C );
48 NORMALIZER_EXPOSE_CLASS_CONST( NFC );
49 NORMALIZER_EXPOSE_CLASS_CONST( FORM_KC );
50 NORMALIZER_EXPOSE_CLASS_CONST( NFKC );
51 #if U_ICU_VERSION_MAJOR_NUM >= 56
52 NORMALIZER_EXPOSE_CLASS_CONST( FORM_KC_CF );
53 NORMALIZER_EXPOSE_CLASS_CONST( NFKC_CF );
54 #endif
55
56 #undef NORMALIZER_EXPOSE_CUSTOM_CLASS_CONST
57 #undef NORMALIZER_EXPOSE_CLASS_CONST
58 #undef NORMALIZER_EXPOSE_CONST
59 }
60 /* }}} */
61