1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-12-04 14:46:47 -05:00

UTF-8: New function cp_to_unicode().

This commit is contained in:
Kalle Olavi Niemitalo 2006-08-13 23:35:50 +03:00 committed by Kalle Olavi Niemitalo
parent 3b54979481
commit b6447ae26b
3 changed files with 22 additions and 5 deletions

View File

@ -320,11 +320,8 @@ select_button_by_key(struct dialog_data *dlg_data)
hk_ptr = widget_data->widget->text;
#ifdef CONFIG_UTF_8
if (is_cp_utf8(codepage))
hk_char = utf_8_to_unicode(&hk_ptr,
hk_char = cp_to_unicode(codepage, &hk_ptr,
strchr(hk_ptr, '\0'));
else
hk_char = cp2u(codepage, *hk_ptr);
hk_char = unicode_fold_label_case(hk_char);
#else
hk_char = toupper(*hk_ptr);

View File

@ -522,6 +522,25 @@ cp2utf_8(int from, int c)
return encode_utf_8(cp2u_shared(&codepages[from], c));
}
#ifdef CONFIG_UTF_8
unicode_val_T
cp_to_unicode(int codepage, unsigned char **string, unsigned char *end)
{
if (is_cp_utf8(codepage))
return utf_8_to_unicode(string, end);
else {
if (*string >= end)
return UCS_NO_CHAR;
else {
unicode_val_T ret = cp2u(codepage, **string);
++*string;
return ret;
}
}
}
#endif /* CONFIG_UTF_8 */
static void
add_utf_8(struct conv_table *ct, unicode_val_T u, unsigned char *str)
{

View File

@ -65,6 +65,7 @@ inline int unicode_to_cell(unicode_val_T);
unicode_val_T unicode_fold_label_case(unicode_val_T);
inline int strlen_utf8(unsigned char **);
inline unicode_val_T utf_8_to_unicode(unsigned char **, unsigned char *);
unicode_val_T cp_to_unicode(int, unsigned char **, unsigned char *);
#endif /* CONFIG_UTF_8 */
unicode_val_T cp2u(int, unsigned char);