1
1

fix: incorrect convert_from_utf_to_current_c, convert_from_utf_to_current

Этот коммит содержится в:
Ilia Maslakov 2009-04-17 10:27:59 +00:00
родитель 0730efa2fc
Коммит 137e3e7259
3 изменённых файлов: 18 добавлений и 10 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -26,7 +26,17 @@ const char *init_translation_table (int cpsource, int cpdisplay);
void convert_to_display (char *str); void convert_to_display (char *str);
void convert_from_input (char *str); void convert_from_input (char *str);
void convert_string (unsigned 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); 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); unsigned char convert_from_utf_to_current_c (const int input_char);
/* Convert single characters */ /* Convert single characters */
static inline int static inline int