| 1 | /* |
| 2 | Copyright (C) 2009-2016 Brazil |
| 3 | Copyright (C) 2018-2025 Sutou Kouhei <[email protected]> |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library 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 GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #pragma once |
| 21 | |
| 22 | #include "grn.h" |
| 23 | |
| 24 | #ifdef __cplusplus |
| 25 | extern "C" { |
| 26 | #endif |
| 27 | |
| 28 | typedef grn_char_type (*grn_nfkc_char_type_func)(const unsigned char *utf8); |
| 29 | typedef const char *(*grn_nfkc_decompose_func)(const unsigned char *utf8); |
| 30 | typedef const char *(*grn_nfkc_compose_func)(const unsigned char *prefix_utf8, |
| 31 | const unsigned char *suffix_utf8); |
| 32 | |
| 33 | typedef struct { |
| 34 | grn_nfkc_char_type_func char_type_func; |
| 35 | grn_nfkc_decompose_func decompose_func; |
| 36 | grn_nfkc_compose_func compose_func; |
| 37 | } grn_nfkc_funcs; |
| 38 | |
| 39 | typedef struct { |
| 40 | grn_nfkc_char_type_func char_type_func; |
| 41 | grn_nfkc_decompose_func decompose_func; |
| 42 | grn_nfkc_compose_func compose_func; |
| 43 | bool include_removed_source_location; |
| 44 | bool report_source_offset; |
| 45 | bool unify_latin_alphabet_with; |
| 46 | bool unify_kana; |
| 47 | bool unify_kana_case; |
| 48 | bool unify_kana_voiced_sound_mark; |
| 49 | bool unify_hyphen; |
| 50 | bool unify_prolonged_sound_mark; |
| 51 | bool unify_hyphen_and_prolonged_sound_mark; |
| 52 | bool unify_middle_dot; |
| 53 | bool unify_katakana_v_sounds; |
| 54 | bool unify_katakana_bu_sound; |
| 55 | bool unify_katakana_du_small_sounds; |
| 56 | bool unify_katakana_du_sound; |
| 57 | bool unify_katakana_zu_small_sounds; |
| 58 | bool unify_katakana_wo_sound; |
| 59 | bool unify_katakana_di_sound; |
| 60 | bool unify_katakana_gu_small_sounds; |
| 61 | bool unify_kana_hyphen; |
| 62 | bool unify_kana_prolonged_sound_mark; |
| 63 | bool unify_katakana_trailing_o; |
| 64 | bool unify_iteration_mark; |
| 65 | bool unify_to_romaji; |
| 66 | bool unify_to_katakana; |
| 67 | bool remove_blank; |
| 68 | bool remove_blank_force; |
| 69 | bool remove_blank_force_is_set; |
| 70 | bool remove_new_line; |
| 71 | bool remove_symbol; |
| 72 | bool strip; |
| 73 | } grn_nfkc_normalize_options; |
| 74 | |
| 75 | typedef void (*grn_nfkc_normalize_options_init_func)(grn_ctx *ctx, |
| 76 | grn_nfkc_normalize_options *options); |
| 77 | |
| 78 | const char *grn_nfkc_decompose(const unsigned char *utf8); |
| 79 | const char *grn_nfkc_compose(const unsigned char *prefix_utf8, |
| 80 | const unsigned char *suffix_utf8); |
| 81 | |
| 82 | GRN_API grn_char_type grn_nfkc50_char_type(const unsigned char *utf8); |
| 83 | const char *grn_nfkc50_decompose(const unsigned char *utf8); |
| 84 | const char *grn_nfkc50_compose(const unsigned char *prefix_utf8, |
| 85 | const unsigned char *suffix_utf8); |
| 86 | |
| 87 | GRN_API grn_char_type grn_nfkc100_char_type(const unsigned char *utf8); |
| 88 | const char *grn_nfkc100_decompose(const unsigned char *utf8); |
| 89 | const char *grn_nfkc100_compose(const unsigned char *prefix_utf8, |
| 90 | const unsigned char *suffix_utf8); |
| 91 | |
| 92 | GRN_API grn_char_type grn_nfkc121_char_type(const unsigned char *utf8); |
| 93 | const char *grn_nfkc121_decompose(const unsigned char *utf8); |
| 94 | const char *grn_nfkc121_compose(const unsigned char *prefix_utf8, |
| 95 | const unsigned char *suffix_utf8); |
| 96 | |
| 97 | GRN_API grn_char_type grn_nfkc130_char_type(const unsigned char *utf8); |
| 98 | const char *grn_nfkc130_decompose(const unsigned char *utf8); |
| 99 | const char *grn_nfkc130_compose(const unsigned char *prefix_utf8, |
| 100 | const unsigned char *suffix_utf8); |
| 101 | |
| 102 | GRN_API grn_char_type grn_nfkc150_char_type(const unsigned char *utf8); |
| 103 | const char *grn_nfkc150_decompose(const unsigned char *utf8); |
| 104 | const char *grn_nfkc150_compose(const unsigned char *prefix_utf8, |
| 105 | const unsigned char *suffix_utf8); |
| 106 | |
| 107 | GRN_API grn_char_type grn_nfkc160_char_type(const unsigned char *utf8); |
| 108 | const char *grn_nfkc160_decompose(const unsigned char *utf8); |
| 109 | const char *grn_nfkc160_compose(const unsigned char *prefix_utf8, |
| 110 | const unsigned char *suffix_utf8); |
| 111 | |
| 112 | GRN_API grn_char_type grn_nfkc170_char_type(const unsigned char *utf8); |
| 113 | const char *grn_nfkc170_decompose(const unsigned char *utf8); |
| 114 | const char *grn_nfkc170_compose(const unsigned char *prefix_utf8, |
| 115 | const unsigned char *suffix_utf8); |
| 116 | |
| 117 | void grn_nfkc_normalize_options_init(grn_ctx *ctx, |
| 118 | grn_nfkc_normalize_options *options, |
| 119 | grn_nfkc_char_type_func char_type_func, |
| 120 | grn_nfkc_decompose_func decompose_func, |
| 121 | grn_nfkc_compose_func compose_func); |
| 122 | void grn_nfkc100_normalize_options_init(grn_ctx *ctx, |
| 123 | grn_nfkc_normalize_options *options); |
| 124 | void grn_nfkc121_normalize_options_init(grn_ctx *ctx, |
| 125 | grn_nfkc_normalize_options *options); |
| 126 | void grn_nfkc130_normalize_options_init(grn_ctx *ctx, |
| 127 | grn_nfkc_normalize_options *options); |
| 128 | void grn_nfkc150_normalize_options_init(grn_ctx *ctx, |
| 129 | grn_nfkc_normalize_options *options); |
| 130 | void grn_nfkc160_normalize_options_init(grn_ctx *ctx, |
| 131 | grn_nfkc_normalize_options *options); |
| 132 | void grn_nfkc170_normalize_options_init(grn_ctx *ctx, |
| 133 | grn_nfkc_normalize_options *options); |
| 134 | grn_nfkc_funcs |
| 135 | grn_nfkc_version_option_process(grn_ctx *ctx, |
| 136 | grn_obj *raw_options, |
| 137 | unsigned int i, |
| 138 | grn_raw_string *name_raw, |
| 139 | const char *tag); |
| 140 | grn_rc grn_nfkc_normalize_options_apply(grn_ctx *ctx, |
| 141 | grn_nfkc_normalize_options *options, |
| 142 | grn_obj *raw_options, |
| 143 | const char *tag); |
| 144 | void grn_nfkc_normalize_options_fin(grn_ctx *ctx, |
| 145 | grn_nfkc_normalize_options *options); |
| 146 | |
| 147 | #ifdef __cplusplus |
| 148 | } |
| 149 | #endif |