mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
fix incorrect convertion from utf to display CP
This commit is contained in:
parent
0934b0643a
commit
8529756be9
@ -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 */
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user