fix: incorrect convert_from_utf_to_current_c, convert_from_utf_to_current

This commit is contained in:
Ilia Maslakov 2009-04-17 10:27:59 +00:00
parent 0730efa2fc
commit 137e3e7259
3 changed files with 18 additions and 10 deletions

View File

@ -434,11 +434,11 @@ edit_draw_this_line (WEdit *edit, long b, long row, long start_col,
default:
if ( utf8_display ) {
if ( !edit->utf8 ) {
//FIXME: if need
}
} else {
if ( edit->utf8 ) {
c = convert_from_utf_to_current_c (c);
//c = convert_to_utf (c);
} else {
c = convert_to_display_c (c);
}

View File

@ -259,23 +259,22 @@ convert_from_utf_to_current (const char *str)
return '.';
unsigned char ch;
char *cp_to = NULL;
char *cp_from = NULL;
GIConv conv;
GString *translated_data;
translated_data = g_string_new ("");
cp_to = g_strdup ( get_codepage_id ( display_codepage ) );
conv = str_crt_conv_to (cp_to);
cp_from = get_codepage_id ( source_codepage );
conv = str_crt_conv_from (cp_from);
if (conv != INVALID_CONV) {
if (str_convert (conv, str, translated_data) != ESTR_FAILURE) {
if (str_convert (conv, (char *) str, translated_data) != ESTR_FAILURE) {
ch = translated_data->str[0];
} else {
ch = '.';
}
str_close_conv (conv);
}
g_free (cp_to);
g_string_free (translated_data, TRUE);
return ch;
@ -287,7 +286,7 @@ convert_from_utf_to_current_c (const int input_char)
unsigned char str[6 + 1];
unsigned char ch = '.';
char *cp_to = NULL;
char *cp_from = NULL;
GIConv conv;
GString *translated_data;
int res = 0;
@ -299,8 +298,8 @@ convert_from_utf_to_current_c (const int input_char)
str[6] = '\0';
translated_data = g_string_new ("");
cp_to = g_strdup ( get_codepage_id ( display_codepage ) );
conv = str_crt_conv_to (cp_to);
cp_from = get_codepage_id ( source_codepage );
conv = str_crt_conv_from (cp_from);
if (conv != INVALID_CONV) {
if (str_convert (conv, str, translated_data) != ESTR_FAILURE) {
@ -310,7 +309,6 @@ convert_from_utf_to_current_c (const int input_char)
}
str_close_conv (conv);
}
g_free (cp_to);
g_string_free (translated_data, TRUE);
return ch;

View File

@ -26,7 +26,17 @@ const char *init_translation_table (int cpsource, int cpdisplay);
void convert_to_display (char *str);
void convert_from_input (char *str);
void convert_string (unsigned char *str);
/*
* Converter from utf to selected codepage
* param str, utf char
* return char in needle codepage (by global int source_codepage)
*/
unsigned char convert_from_utf_to_current (const char *str);
/*
* Converter from utf to selected codepage
* param input_char, gunichar
* return char in needle codepage (by global int source_codepage)
*/
unsigned char convert_from_utf_to_current_c (const int input_char);
/* Convert single characters */
static inline int