normalizer.c 2.2 KB

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