Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * Copyright 2005 John M Bell <jmb202@ecs.soton.ac.uk>
  3.  *
  4.  * This file is part of NetSurf, http://www.netsurf-browser.org/
  5.  *
  6.  * NetSurf is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; version 2 of the License.
  9.  *
  10.  * NetSurf is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17.  */
  18.  
  19. /** \file
  20.  * UTF-8 manipulation functions (interface).
  21.  */
  22.  
  23.  typedef signed char int8_t;
  24. typedef signed short int16_t;
  25. typedef signed int int32_t;
  26.  
  27. typedef unsigned char uint8_t;
  28. typedef unsigned short uint16_t;
  29. typedef unsigned int uint32_t;
  30.  
  31.  
  32. #ifndef _NETSURF_UTILS_UTF8_H_
  33. #define _NETSURF_UTILS_UTF8_H_
  34.  
  35. #include <stdint.h>
  36.  
  37. typedef enum {
  38.         UTF8_CONVERT_OK,
  39.         UTF8_CONVERT_NOMEM,
  40.         UTF8_CONVERT_BADENC
  41. } utf8_convert_ret;
  42.  
  43. uint32_t utf8_to_ucs4(const char *s, size_t l);
  44. size_t utf8_from_ucs4(uint32_t c, char *s);
  45.  
  46. size_t utf8_length(const char *s);
  47. size_t utf8_bounded_length(const char *s, size_t l);
  48.  
  49. size_t utf8_char_byte_length(const char *s);
  50.  
  51. size_t utf8_prev(const char *s, size_t o);
  52. size_t utf8_next(const char *s, size_t l, size_t o);
  53.  
  54. utf8_convert_ret utf8_to_enc(const char *string, const char *encname,
  55.                 size_t len, char **result);
  56. utf8_convert_ret utf8_from_enc(const char *string, const char *encname,
  57.                 size_t len, char **result);
  58.  
  59. utf8_convert_ret utf8_to_html(const char *string, const char *encname,
  60.                 size_t len, char **result);
  61.  
  62. /* These two are platform specific */
  63. utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
  64.                 char **result);
  65. utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len,
  66.                 char **result);
  67.  
  68. void utf8_finalise(void);
  69.  
  70. #endif
  71.