uchardet.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. *
  24. * Alternatively, the contents of this file may be used under the terms of
  25. * either the GNU General Public License Version 2 or later (the "GPL"), or
  26. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  27. * in which case the provisions of the GPL or the LGPL are applicable instead
  28. * of those above. If you wish to allow use of your version of this file only
  29. * under the terms of either the GPL or the LGPL, and not to allow others to
  30. * use your version of this file under the terms of the MPL, indicate your
  31. * decision by deleting the provisions above and replace them with the notice
  32. * and other provisions required by the GPL or the LGPL. If you do not delete
  33. * the provisions above, a recipient may use your version of this file under
  34. * the terms of any one of the MPL, the GPL or the LGPL.
  35. *
  36. * ***** END LICENSE BLOCK ***** */
  37. #ifndef UCHARDET_H___
  38. #define UCHARDET_H___
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. #include <stddef.h>
  43. typedef struct uchardet * uchardet_t;
  44. /**
  45. * Create an encoding detector.
  46. * @return a handle of a instance of uchardet
  47. */
  48. uchardet_t uchardet_new(void);
  49. /**
  50. * Delete an encoding detector.
  51. * @param ud [in] handle of a instance of uchardet
  52. */
  53. void uchardet_delete(uchardet_t ud);
  54. /**
  55. * Feed data to an encoding detector.
  56. * @param ud [in] handle of a instance of uchardet
  57. * @param data [in] data
  58. * @param len [in] number of byte of data
  59. * @return non-zero number on failure.
  60. */
  61. int uchardet_handle_data(uchardet_t ud, const char * data, size_t len);
  62. /**
  63. * Notify an end of data to an encoding detctor.
  64. * @param ud [in] handle of a instance of uchardet
  65. */
  66. void uchardet_data_end(uchardet_t ud);
  67. /**
  68. * Reset an encoding detector.
  69. * @param ud [in] handle of a instance of uchardet
  70. */
  71. void uchardet_reset(uchardet_t ud);
  72. /**
  73. * Get an iconv-compatible name of the encoding that was detected.
  74. * @param ud [in] handle of a instance of uchardet
  75. * @return name of charset on success and "" on failure.
  76. */
  77. const char * uchardet_get_charset(uchardet_t ud);
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif