fix: input in 8-bit locales

This commit is contained in:
Ilia Maslakov 2009-04-19 12:18:18 +00:00
parent 28425d427f
commit b87edfdc26
2 changed files with 9 additions and 12 deletions

View File

@ -247,7 +247,6 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
/* an ordinary insertable character */
if (x_key < 256 && !extmod) {
if ( edit->charpoint >= 4 ) {
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 {
//FIXME: need more think about
//must be return multibyte char
//must be return multibyte char but this func return 8bit char
}
/* UTF-8 locale */
} else {
@ -315,7 +314,6 @@ edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch)
/* unprinteble utf input, skip it */
edit->charbuf[0] = '\0';
edit->charpoint = 0;
goto fin;
}
}
}

View File

@ -302,27 +302,26 @@ convert_from_utf_to_current (const char *str)
return '.';
unsigned char buf_ch[6 + 1];
unsigned char ch;
char *cp_from = NULL;
unsigned char ch = '.';
char *cp_to = NULL;
GIConv conv;
int res = 0;
cp_from = get_codepage_id ( source_codepage );
conv = str_crt_conv_from ( cp_from );
cp_to = get_codepage_id ( source_codepage );
conv = str_crt_conv_to ( cp_to );
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:
ch = buf_ch[0];
break;
case 1:
ch = '.';
break;
case 2:
ch = '.';
break;
}
str_close_conv (conv);
}
return ch;
}
@ -349,7 +348,7 @@ convert_from_utf_to_current_c (const int input_char)
conv = str_crt_conv_from (cp_from);
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:
ch = buf_ch[0];
break;