mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-01 00:54:24 +03:00
Fix search with 8-bit system codepage in utf-8 text codepage
This commit is contained in:
parent
9da8faa62d
commit
95e2fb90ef
@ -2137,17 +2137,30 @@ void edit_search_cmd (WEdit * edit, int again)
|
||||
return;
|
||||
exp = g_strdup (old);
|
||||
} else {
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (exp && *exp)
|
||||
convert_to_display (exp);
|
||||
if (exp && *exp){
|
||||
GString *tmp = str_convert_to_display (exp);
|
||||
if (tmp && tmp->len){
|
||||
g_free(exp);
|
||||
exp = tmp->str;
|
||||
}
|
||||
if (tmp)
|
||||
g_string_free(tmp,FALSE);
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
||||
edit_search_dialog (edit, &exp);
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
if (exp && *exp)
|
||||
convert_from_input (exp);
|
||||
if (exp && *exp){
|
||||
GString *tmp = str_convert_from_input (exp);
|
||||
if (tmp && tmp->len){
|
||||
g_free(exp);
|
||||
exp = tmp->str;
|
||||
}
|
||||
if (tmp)
|
||||
g_string_free(tmp,FALSE);
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
edit_push_action (edit, KEY_PRESS + edit->start_display);
|
||||
}
|
||||
|
@ -39,6 +39,10 @@ struct codepage_desc *codepages;
|
||||
unsigned char conv_displ[256];
|
||||
unsigned char conv_input[256];
|
||||
|
||||
static char *cp_display = NULL;
|
||||
static char *cp_source = NULL;
|
||||
|
||||
|
||||
int
|
||||
load_codepages_list (void)
|
||||
{
|
||||
@ -191,8 +195,8 @@ init_translation_table (int cpsource, int cpdisplay)
|
||||
conv_input[i] = i;
|
||||
}
|
||||
|
||||
cpsour = codepages[cpsource].id;
|
||||
cpdisp = codepages[cpdisplay].id;
|
||||
cp_display = cpsour = codepages[cpsource].id;
|
||||
cp_source = cpdisp = codepages[cpdisplay].id;
|
||||
|
||||
/* display <- inpit table */
|
||||
|
||||
@ -240,6 +244,25 @@ convert_to_display (char *str)
|
||||
}
|
||||
}
|
||||
|
||||
GString *
|
||||
str_convert_to_display (char *str)
|
||||
{
|
||||
GString *buff;
|
||||
GIConv conv;
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
if (cp_display == cp_source)
|
||||
return g_string_new(str);
|
||||
|
||||
conv = str_crt_conv_from (cp_source);
|
||||
|
||||
buff = g_string_new("");
|
||||
str_convert (conv, str, buff);
|
||||
return buff;
|
||||
}
|
||||
|
||||
void
|
||||
convert_from_input (char *str)
|
||||
{
|
||||
@ -252,6 +275,25 @@ convert_from_input (char *str)
|
||||
}
|
||||
}
|
||||
|
||||
GString *
|
||||
str_convert_from_input (char *str)
|
||||
{
|
||||
GString *buff;
|
||||
GIConv conv;
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
if (cp_display == cp_source)
|
||||
return g_string_new(str);
|
||||
|
||||
conv = str_crt_conv_to (cp_display);
|
||||
|
||||
buff = g_string_new("");
|
||||
str_convert (conv, str, buff);
|
||||
return buff;
|
||||
}
|
||||
|
||||
unsigned char
|
||||
convert_from_utf_to_current (const char *str)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user