fix incorrect convertion from utf to display CP

This commit is contained in:
Ilia Maslakov 2009-04-16 15:10:51 +00:00
parent 0934b0643a
commit 8529756be9
2 changed files with 33 additions and 1 deletions

View File

@ -29,6 +29,8 @@
#include "global.h"
#include "charsets.h"
#include "strutil.h" /* utf-8 functions */
#include "main.h"
int n_codepages = 0;
@ -249,4 +251,34 @@ convert_from_input (char *str)
str++;
}
}
unsigned char
convert_from_utf_to_current (char *str)
{
if (!str)
return '.';
unsigned char ch;
char *cp_to = 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);
if (conv != INVALID_CONV) {
if (str_convert (conv, 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;
}
#endif /* HAVE_CHARSET */

View File

@ -6,7 +6,6 @@
#define UNKNCHAR '\001'
#define CHARSETS_INDEX "mc.charsets"
extern int n_codepages;
extern unsigned char conv_displ[256];
@ -27,6 +26,7 @@ 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);
unsigned char convert_from_utf_to_current (char *str);
/* Convert single characters */
static inline int