zend_multibyte.h 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Zend Engine |
  4. +----------------------------------------------------------------------+
  5. | Copyright (c) Zend Technologies Ltd. (http://www.zend.com) |
  6. +----------------------------------------------------------------------+
  7. | This source file is subject to version 2.00 of the Zend license, |
  8. | that is bundled with this package in the file LICENSE, and is |
  9. | available through the world-wide-web at |
  10. | http://www.zend.com/license/2_00.txt. |
  11. | If you did not receive a copy of the Zend license and are unable to |
  12. | obtain it through the world-wide-web, please send a note to |
  13. | license@zend.com so we can mail you a copy immediately. |
  14. +----------------------------------------------------------------------+
  15. | Authors: Masaki Fujimoto <fujimoto@php.net> |
  16. | Rui Hirokawa <hirokawa@php.net> |
  17. +----------------------------------------------------------------------+
  18. */
  19. #ifndef ZEND_MULTIBYTE_H
  20. #define ZEND_MULTIBYTE_H
  21. typedef struct _zend_encoding zend_encoding;
  22. typedef size_t (*zend_encoding_filter)(unsigned char **str, size_t *str_length, const unsigned char *buf, size_t length);
  23. typedef const zend_encoding* (*zend_encoding_fetcher)(const char *encoding_name);
  24. typedef const char* (*zend_encoding_name_getter)(const zend_encoding *encoding);
  25. typedef bool (*zend_encoding_lexer_compatibility_checker)(const zend_encoding *encoding);
  26. typedef const zend_encoding *(*zend_encoding_detector)(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
  27. typedef size_t (*zend_encoding_converter)(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
  28. typedef zend_result (*zend_encoding_list_parser)(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent);
  29. typedef const zend_encoding *(*zend_encoding_internal_encoding_getter)(void);
  30. typedef zend_result (*zend_encoding_internal_encoding_setter)(const zend_encoding *encoding);
  31. typedef struct _zend_multibyte_functions {
  32. const char *provider_name;
  33. zend_encoding_fetcher encoding_fetcher;
  34. zend_encoding_name_getter encoding_name_getter;
  35. zend_encoding_lexer_compatibility_checker lexer_compatibility_checker;
  36. zend_encoding_detector encoding_detector;
  37. zend_encoding_converter encoding_converter;
  38. zend_encoding_list_parser encoding_list_parser;
  39. zend_encoding_internal_encoding_getter internal_encoding_getter;
  40. zend_encoding_internal_encoding_setter internal_encoding_setter;
  41. } zend_multibyte_functions;
  42. /*
  43. * zend multibyte APIs
  44. */
  45. BEGIN_EXTERN_C()
  46. ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf32be;
  47. ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf32le;
  48. ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16be;
  49. ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf16le;
  50. ZEND_API extern const zend_encoding *zend_multibyte_encoding_utf8;
  51. /* multibyte utility functions */
  52. ZEND_API zend_result zend_multibyte_set_functions(const zend_multibyte_functions *functions);
  53. ZEND_API void zend_multibyte_restore_functions(void);
  54. ZEND_API const zend_multibyte_functions *zend_multibyte_get_functions(void);
  55. ZEND_API const zend_encoding *zend_multibyte_fetch_encoding(const char *name);
  56. ZEND_API const char *zend_multibyte_get_encoding_name(const zend_encoding *encoding);
  57. ZEND_API int zend_multibyte_check_lexer_compatibility(const zend_encoding *encoding);
  58. ZEND_API const zend_encoding *zend_multibyte_encoding_detector(const unsigned char *string, size_t length, const zend_encoding **list, size_t list_size);
  59. ZEND_API size_t zend_multibyte_encoding_converter(unsigned char **to, size_t *to_length, const unsigned char *from, size_t from_length, const zend_encoding *encoding_to, const zend_encoding *encoding_from);
  60. ZEND_API int zend_multibyte_parse_encoding_list(const char *encoding_list, size_t encoding_list_len, const zend_encoding ***return_list, size_t *return_size, bool persistent);
  61. ZEND_API const zend_encoding *zend_multibyte_get_internal_encoding(void);
  62. ZEND_API const zend_encoding *zend_multibyte_get_script_encoding(void);
  63. ZEND_API int zend_multibyte_set_script_encoding(const zend_encoding **encoding_list, size_t encoding_list_size);
  64. ZEND_API int zend_multibyte_set_internal_encoding(const zend_encoding *encoding);
  65. ZEND_API zend_result zend_multibyte_set_script_encoding_by_string(const char *new_value, size_t new_value_length);
  66. END_EXTERN_C()
  67. #endif /* ZEND_MULTIBYTE_H */