mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
fix: input in 8-bit locales
This commit is contained in:
parent
28425d427f
commit
b87edfdc26
@ -247,7 +247,6 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||||||
|
|
||||||
/* an ordinary insertable character */
|
/* an ordinary insertable character */
|
||||||
if (x_key < 256 && !extmod) {
|
if (x_key < 256 && !extmod) {
|
||||||
|
|
||||||
if ( edit->charpoint >= 4 ) {
|
if ( edit->charpoint >= 4 ) {
|
||||||
edit->charpoint = 0;
|
edit->charpoint = 0;
|
||||||
edit->charbuf[edit->charpoint] = '\0';
|
edit->charbuf[edit->charpoint] = '\0';
|
||||||
@ -268,7 +267,7 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//FIXME: need more think about
|
//FIXME: need more think about
|
||||||
//must be return multibyte char
|
//must be return multibyte char but this func return 8bit char
|
||||||
}
|
}
|
||||||
/* UTF-8 locale */
|
/* UTF-8 locale */
|
||||||
} else {
|
} else {
|
||||||
@ -315,7 +314,6 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
|
|||||||
/* unprinteble utf input, skip it */
|
/* unprinteble utf input, skip it */
|
||||||
edit->charbuf[0] = '\0';
|
edit->charbuf[0] = '\0';
|
||||||
edit->charpoint = 0;
|
edit->charpoint = 0;
|
||||||
goto fin;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,27 +302,26 @@ convert_from_utf_to_current (const char *str)
|
|||||||
return '.';
|
return '.';
|
||||||
|
|
||||||
unsigned char buf_ch[6 + 1];
|
unsigned char buf_ch[6 + 1];
|
||||||
unsigned char ch;
|
unsigned char ch = '.';
|
||||||
char *cp_from = NULL;
|
char *cp_to = NULL;
|
||||||
GIConv conv;
|
GIConv conv;
|
||||||
int res = 0;
|
|
||||||
|
|
||||||
cp_from = get_codepage_id ( source_codepage );
|
cp_to = get_codepage_id ( source_codepage );
|
||||||
conv = str_crt_conv_from ( cp_from );
|
conv = str_crt_conv_to ( cp_to );
|
||||||
|
|
||||||
if (conv != INVALID_CONV) {
|
if (conv != INVALID_CONV) {
|
||||||
switch (str_translate_char (conv, str, res, buf_ch, sizeof(buf_ch))) {
|
switch (str_translate_char (conv, str, -1, buf_ch, sizeof(buf_ch))) {
|
||||||
case 0:
|
case 0:
|
||||||
ch = buf_ch[0];
|
ch = buf_ch[0];
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
ch = '.';
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
ch = '.';
|
ch = '.';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
str_close_conv (conv);
|
str_close_conv (conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ch;
|
return ch;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -349,7 +348,7 @@ convert_from_utf_to_current_c (const int input_char)
|
|||||||
conv = str_crt_conv_from (cp_from);
|
conv = str_crt_conv_from (cp_from);
|
||||||
|
|
||||||
if (conv != INVALID_CONV) {
|
if (conv != INVALID_CONV) {
|
||||||
switch (str_translate_char (conv, str, res, buf_ch, sizeof(buf_ch))) {
|
switch (str_translate_char (conv, str, sizeof(str), buf_ch, sizeof(buf_ch))) {
|
||||||
case 0:
|
case 0:
|
||||||
ch = buf_ch[0];
|
ch = buf_ch[0];
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user