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