X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/caecd4f412422d8130d616da33325e03557218e7..a89e0ecf7c67ef6af6678985060a0d8e7bae5fba:/lib/unicode.h diff --git a/lib/unicode.h b/lib/unicode.h index 47b39f0..b6d6813 100644 --- a/lib/unicode.h +++ b/lib/unicode.h @@ -2,20 +2,18 @@ * This file is part of DisOrde * Copyright (C) 2007 Richard Kettlewell * - * This program is free software; you can redistribute it and/or modify + * This program 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; either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * - * This program 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. - * + * + * This program 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, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA + * along with this program. If not, see . */ /** @file lib/unicode.h * @brief Unicode support functions @@ -36,10 +34,20 @@ */ typedef struct utf32_iterator_data *utf32_iterator; +/** @brief Property tailor function + * @param c Code point + * @return Tailored property or -1 to use standard value + * + * See also utf32_iterator_tailor_word_break(). + */ +typedef int unicode_property_tailor(uint32_t c); + char *utf32_to_utf8(const uint32_t *s, size_t ns, size_t *nd); uint32_t *utf8_to_utf32(const char *s, size_t ns, size_t *nd); int utf8_valid(const char *s, size_t ns); +int utf32_combining_class(uint32_t c); + size_t utf32_len(const uint32_t *s); int utf32_cmp(const uint32_t *a, const uint32_t *b); @@ -49,6 +57,12 @@ char *utf8_decompose_canon(const char *s, size_t ns, size_t *ndp); uint32_t *utf32_decompose_compat(const uint32_t *s, size_t ns, size_t *ndp); char *utf8_decompose_compat(const char *s, size_t ns, size_t *ndp); +uint32_t *utf32_compose_canon(const uint32_t *s, size_t ns, size_t *ndp); +char *utf8_compose_canon(const char *s, size_t ns, size_t *ndp); + +uint32_t *utf32_compose_compat(const uint32_t *s, size_t ns, size_t *ndp); +char *utf8_compose_compat(const char *s, size_t ns, size_t *ndp); + uint32_t *utf32_casefold_canon(const uint32_t *s, size_t ns, size_t *ndp); char *utf8_casefold_canon(const char *s, size_t ns, size_t *ndp); @@ -67,6 +81,13 @@ int utf32_iterator_advance(utf32_iterator it, size_t n); uint32_t utf32_iterator_code(utf32_iterator it); int utf32_iterator_grapheme_boundary(utf32_iterator it); int utf32_iterator_word_boundary(utf32_iterator it); +void utf32_iterator_tailor_word_break(utf32_iterator it, + unicode_property_tailor *pt); + +uint32_t **utf32_word_split(const uint32_t *s, size_t ns, size_t *nwp, + unicode_property_tailor *wbreak); +char **utf8_word_split(const char *s, size_t ns, size_t *nwp, + unicode_property_tailor *wbreak); /** @brief Convert 0-terminated UTF-32 to UTF-8 * @param s 0-terminated UTF-32 string