normalizer_api.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. #############################################################################
  3. # Object-oriented API
  4. #############################################################################
  5. /**
  6. * Normalizer class.
  7. *
  8. * Normalizer provides access to Unicode normalization of strings. This class consists
  9. * only of static methods. The iterator interface to normalizer is rarely used, so is
  10. * not provided here.
  11. *
  12. * Example:
  13. * <code>
  14. *
  15. * </code>
  16. *
  17. * @see http://www.icu-project.org/apiref/icu4c/unorm_8h.html
  18. * @see http://www.icu-project.org/apiref/icu4c/classNormalizer.html
  19. *
  20. */
  21. class Normalizer {
  22. #############################################################################
  23. # Common constants.
  24. #############################################################################
  25. /**
  26. * Valid normalization form values.
  27. *
  28. * @see Normalizer::normalize()
  29. * @see Normalizer::isNormalize()
  30. * @see normalizer_normalize()
  31. * @see normalizer_is_normalized()
  32. */
  33. const NONE = 1;
  34. /** Canonical decomposition. */
  35. const NFD = 2;
  36. const FORM_D = NFD;
  37. /** Compatibility decomposition. */
  38. const NFKD = 3;
  39. const FORM_KD = NFKD;
  40. /** Canonical decomposition followed by canonical composition. */
  41. const NFC = 4;
  42. const FORM_C = NFC;
  43. /** Compatibility decomposition followed by canonical composition. */
  44. const NFKC =5;
  45. const FORM_KC = NFKC;
  46. /**
  47. * Normalizes the input provided and returns the normalized string
  48. * @param string $input The input string to normalize
  49. * @param [int] $form One of the normalization forms
  50. * @return string The normalized string or null if an error occurred.
  51. */
  52. public static function normalize($input, $form = Normalizer::FORM_C) {}
  53. /**
  54. * Checks if the provided string is already in the specified normalization form.
  55. * @param string $input The input string to normalize
  56. * @param [int] $form One of the normalization forms
  57. * @return boolean True if normalized, false otherwise or if there is an error
  58. */
  59. public static function isNormalized($input, $form = Normalizer::FORM_C) {}
  60. }
  61. #############################################################################
  62. # Procedural API
  63. #############################################################################
  64. /**
  65. * Normalizes the input provided and returns the normalized string
  66. * @param string $input The input string to normalize
  67. * @param [int] $form One of the normalization forms
  68. * @return string The normalized string or null if an error occurred.
  69. */
  70. function normalizer_normalize($input, $form = Normalizer::FORM_C) {}
  71. /**
  72. * Checks if the provided string is already in the specified normalization form.
  73. * @param string $input The input string to normalize
  74. * @param [int] $form One of the normalization forms
  75. * @return boolean True if normalized, false otherwise or if there an error
  76. */
  77. function normalizer_is_normalized($input, $form = Normalizer::FORM_C) {}
  78. ?>