uchardet.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /* ***** BEGIN LICENSE BLOCK *****
  2. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  3. *
  4. * The contents of this file are subject to the Mozilla Public License Version
  5. * 1.1 (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. * http://www.mozilla.org/MPL/
  8. *
  9. * Software distributed under the License is distributed on an "AS IS" basis,
  10. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. * for the specific language governing rights and limitations under the
  12. * License.
  13. *
  14. * The Original Code is Mozilla Universal charset detector code.
  15. *
  16. * The Initial Developer of the Original Code is
  17. * Netscape Communications Corporation.
  18. * Portions created by the Initial Developer are Copyright (C) 2001
  19. * the Initial Developer. All Rights Reserved.
  20. *
  21. * Contributor(s):
  22. * BYVoid <byvoid.kcp@gmail.com>
  23. * Jehan <jehan at girinstud.io>
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. #ifndef UCHARDET_H___
  39. #define UCHARDET_H___
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. #include <stddef.h>
  44. /**
  45. * A handle for a uchardet encoding detector.
  46. */
  47. typedef struct uchardet * uchardet_t;
  48. /**
  49. * Create an encoding detector.
  50. * @return an instance of uchardet_t.
  51. */
  52. uchardet_t uchardet_new(void);
  53. /**
  54. * Delete an encoding detector.
  55. * @param ud [in] the uchardet_t handle to delete.
  56. */
  57. void uchardet_delete(uchardet_t ud);
  58. /**
  59. * Feed data to an encoding detector.
  60. * The detector is able to shortcut processing when it reaches certainty
  61. * for an encoding, so you should not worry about limiting input data.
  62. * As far as you should be concerned: the more the better.
  63. *
  64. * @param ud [in] handle of a instance of uchardet
  65. * @param data [in] data
  66. * @param len [in] number of byte of data
  67. * @return non-zero number on failure.
  68. */
  69. int uchardet_handle_data(uchardet_t ud, const char * data, size_t len);
  70. /**
  71. * Notify an end of data to an encoding detctor.
  72. * @param ud [in] handle of a instance of uchardet
  73. */
  74. void uchardet_data_end(uchardet_t ud);
  75. /**
  76. * Reset an encoding detector.
  77. * @param ud [in] handle of a instance of uchardet
  78. */
  79. void uchardet_reset(uchardet_t ud);
  80. /**
  81. * Get an iconv-compatible name of the encoding that was detected.
  82. * @param ud [in] handle of a instance of uchardet
  83. * @return name of charset on success and "" on failure.
  84. */
  85. const char * uchardet_get_charset(uchardet_t ud);
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif