mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
fix: incorret draw files in 8-bit codeset after recode
This commit is contained in:
parent
e88a6bd4d8
commit
a4b354f99c
@ -434,7 +434,7 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
|
||||
default:
|
||||
if ( utf8_display ) {
|
||||
if ( !edit->utf8 ) {
|
||||
//FIXME: if need
|
||||
c = convert_from_8bit_to_utf_c ((unsigned char) c);
|
||||
}
|
||||
} else {
|
||||
if ( edit->utf8 ) {
|
||||
|
@ -364,4 +364,41 @@ convert_from_utf_to_current_c (const int input_char)
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
convert_from_8bit_to_utf_c (const char input_char)
|
||||
{
|
||||
unsigned char str[2];
|
||||
unsigned char buf_ch[6 + 1];
|
||||
int ch = '.';
|
||||
int res = 0;
|
||||
char *cp_from = NULL;
|
||||
GIConv conv;
|
||||
GString *translated_data;
|
||||
|
||||
str[0] = (unsigned char) input_char;
|
||||
str[1] = '\0';
|
||||
|
||||
cp_from = get_codepage_id ( source_codepage );
|
||||
conv = str_crt_conv_from (cp_from);
|
||||
|
||||
if (conv != INVALID_CONV) {
|
||||
switch (str_translate_char (conv, str, -1, buf_ch, sizeof(buf_ch))) {
|
||||
case 0:
|
||||
res = g_utf8_get_char_validated (buf_ch, -1);
|
||||
if ( res < 0 ) {
|
||||
ch = buf_ch[0];
|
||||
} else {
|
||||
ch = res;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
ch = '.';
|
||||
break;
|
||||
}
|
||||
str_close_conv (conv);
|
||||
}
|
||||
return ch;
|
||||
|
||||
}
|
||||
#endif /* HAVE_CHARSET */
|
||||
|
@ -38,6 +38,13 @@ unsigned char convert_from_utf_to_current (const char *str);
|
||||
* return char in needle codepage (by global int source_codepage)
|
||||
*/
|
||||
unsigned char convert_from_utf_to_current_c (const int input_char);
|
||||
/*
|
||||
* Converter from selected codepage 8-bit
|
||||
* param char input_char
|
||||
* return int utf char
|
||||
*/
|
||||
int convert_from_8bit_to_utf_c (const char input_char);
|
||||
|
||||
/* Convert single characters */
|
||||
static inline int
|
||||
convert_to_display_c (int c)
|
||||
|
Loading…
Reference in New Issue
Block a user