2005-04-16 09:09:33 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2005 John M Bell <jmb202@ecs.soton.ac.uk>
|
2007-08-08 20:16:03 +04:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-04-16 09:09:33 +04:00
|
|
|
*/
|
|
|
|
|
2005-07-02 22:18:48 +04:00
|
|
|
/** \file
|
|
|
|
* UTF-8 manipulation functions (interface).
|
2005-04-16 09:09:33 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _NETSURF_UTILS_UTF8_H_
|
|
|
|
#define _NETSURF_UTILS_UTF8_H_
|
|
|
|
|
2013-02-22 17:31:51 +04:00
|
|
|
#include <stdbool.h>
|
2009-02-18 02:44:17 +03:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2005-06-08 01:29:26 +04:00
|
|
|
typedef enum {
|
|
|
|
UTF8_CONVERT_OK,
|
|
|
|
UTF8_CONVERT_NOMEM,
|
|
|
|
UTF8_CONVERT_BADENC
|
|
|
|
} utf8_convert_ret;
|
|
|
|
|
2009-02-18 02:44:17 +03:00
|
|
|
uint32_t utf8_to_ucs4(const char *s, size_t l);
|
|
|
|
size_t utf8_from_ucs4(uint32_t c, char *s);
|
2005-04-16 09:09:33 +04:00
|
|
|
|
|
|
|
size_t utf8_length(const char *s);
|
2009-02-18 02:44:17 +03:00
|
|
|
size_t utf8_bounded_length(const char *s, size_t l);
|
2013-03-18 02:01:42 +04:00
|
|
|
size_t utf8_bounded_byte_length(const char *s, size_t l, size_t c);
|
2009-02-18 02:44:17 +03:00
|
|
|
|
|
|
|
size_t utf8_char_byte_length(const char *s);
|
2005-04-16 09:09:33 +04:00
|
|
|
|
|
|
|
size_t utf8_prev(const char *s, size_t o);
|
|
|
|
size_t utf8_next(const char *s, size_t l, size_t o);
|
|
|
|
|
2005-06-08 01:29:26 +04:00
|
|
|
utf8_convert_ret utf8_to_enc(const char *string, const char *encname,
|
|
|
|
size_t len, char **result);
|
|
|
|
utf8_convert_ret utf8_from_enc(const char *string, const char *encname,
|
|
|
|
size_t len, char **result);
|
2005-04-16 09:09:33 +04:00
|
|
|
|
2012-12-31 03:33:27 +04:00
|
|
|
utf8_convert_ret utf8_to_html(const char *string, const char *encname,
|
|
|
|
size_t len, char **result);
|
|
|
|
|
2013-02-22 16:19:35 +04:00
|
|
|
bool utf8_save_text(const char *utf8_text, const char *path);
|
|
|
|
|
2005-07-16 18:35:25 +04:00
|
|
|
/* These two are platform specific */
|
|
|
|
utf8_convert_ret utf8_to_local_encoding(const char *string, size_t len,
|
|
|
|
char **result);
|
|
|
|
utf8_convert_ret utf8_from_local_encoding(const char *string, size_t len,
|
|
|
|
char **result);
|
|
|
|
|
2005-07-11 22:10:10 +04:00
|
|
|
void utf8_finalise(void);
|
|
|
|
|
2005-04-16 09:09:33 +04:00
|
|
|
#endif
|