diff --git a/edit/editdraw.c b/edit/editdraw.c index bb21d4108..17e8cbdba 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -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 ) { diff --git a/src/charsets.c b/src/charsets.c index 78be20610..5da8d127b 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -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 */ diff --git a/src/charsets.h b/src/charsets.h index 34c490199..04f0c0793 100644 --- a/src/charsets.h +++ b/src/charsets.h @@ -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)