'other 8 bit'
- From: Andy Shevchenko <andy pylesos interdon net>
- To: MC Devel <mc-devel gnome org>
- Subject: 'other 8 bit'
- Date: Wed, 18 May 2005 11:42:57 +0300
Hi!
I use mc in other locales with charset conversion (--enable-charset,
Ctrl-T in viewer). However, I confused by 'Other 8 bit' item in that
conversion menu. I prefer to use current locale charmap.
Who can explain me the main purpose of that?
P.S> In attached patch I have changed 'Other 8 bit' to 'Current
charmap'. At begin, the discussion had started here:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=155974
Thanks for replying!
--
With best regards,
Andy Shevchenko. mailto: andy smile org ua
--- mc-4.6.1-pre3/src/boxes.c.current-charmap 2005-04-27 12:54:29.000000000 +0300
+++ mc-4.6.1-pre3/src/boxes.c 2005-04-27 12:54:29.000000000 +0300
@@ -554,7 +554,7 @@ sel_charset_button (int action)
char buf[64];
new_display_codepage = select_charset (new_display_codepage, 1);
cpname = (new_display_codepage < 0)
- ? _("Other 8 bit")
+ ? _("Current charmap")
: codepages[new_display_codepage].name;
/* avoid strange bug with label repainting */
@@ -579,7 +579,7 @@ init_disp_bits_box (void)
label_new (3, 4, _("Input / display codepage:")));
cpname = (new_display_codepage < 0)
- ? _("Other 8 bit")
+ ? _("Current charmap")
: codepages[new_display_codepage].name;
cplabel = label_new (4, 4, cpname);
add_widget (dbits_dlg, cplabel);
--- mc-4.6.1-pre3/src/selcodepage.c.current-charmap 2004-09-01 20:46:53.000000000 +0300
+++ mc-4.6.1-pre3/src/selcodepage.c 2005-04-27 12:54:29.000000000 +0300
@@ -67,7 +67,7 @@ select_charset (int current_charset, int
}
if (seldisplay) {
g_snprintf (buffer, sizeof (buffer), "%c %s",
- get_hotkey (n_codepages), _("Other 8 bit"));
+ get_hotkey (n_codepages), _("Current charmap"));
LISTBOX_APPEND_TEXT (listbox, get_hotkey (n_codepages), buffer,
NULL);
}
@@ -93,19 +93,11 @@ do_select_codepage (void)
{
const char *errmsg;
- if (display_codepage > 0) {
- source_codepage = select_charset (source_codepage, 0);
- errmsg =
- init_translation_table (source_codepage, display_codepage);
- if (errmsg) {
- message (1, MSG_ERROR, "%s", errmsg);
- return -1;
- }
- } else {
- message (1, _("Warning"),
- _("To use this feature select your codepage in\n"
- "Setup / Display Bits dialog!\n"
- "Do not forget to save options."));
+ source_codepage = select_charset (source_codepage, 0);
+ errmsg =
+ init_translation_table (source_codepage, display_codepage);
+ if (errmsg) {
+ message (1, MSG_ERROR, "%s", errmsg);
return -1;
}
return 0;
--- mc-4.6.1-pre3/src/charsets.c.current-charmap 2004-08-30 13:38:00.000000000 +0300
+++ mc-4.6.1-pre3/src/charsets.c 2005-04-27 12:59:57.000000000 +0300
@@ -24,8 +28,11 @@
#include <stdio.h>
#include <string.h>
#include <iconv.h>
+#include <langinfo.h>
+#include <locale.h>
#include "global.h"
+#include "tty.h" /* UTF8 */
#include "charsets.h"
int n_codepages = 0;
@@ -35,6 +42,21 @@ struct codepage_desc *codepages;
unsigned char conv_displ[256];
unsigned char conv_input[256];
+static const char *
+get_current_charmap (void)
+{
+ static int init = -1;
+ static char *charmap = NULL;
+
+ if (init == -1) {
+ char *lc_ctype = setlocale (LC_CTYPE, "");
+ charmap = nl_langinfo (CODESET);
+ setlocale (LC_CTYPE, lc_ctype);
+ init = 0;
+ }
+ return charmap;
+}
+
int
load_codepages_list (void)
{
@@ -119,19 +141,17 @@ free_codepages_list (void)
}
}
-#define OTHER_8BIT "Other_8_bit"
-
const char *
get_codepage_id (int n)
{
- return (n < 0) ? OTHER_8BIT : codepages[n].id;
+ return (n < 0) ? get_current_charmap () : codepages[n].id;
}
int
get_codepage_index (const char *id)
{
int i;
- if (strcmp (id, OTHER_8BIT) == 0)
+ if (strcmp (id, get_current_charmap ()) == 0)
return -1;
for (i = 0; codepages[i].id; ++i)
if (strcmp (id, codepages[i].id) == 0)
@@ -172,9 +192,17 @@ init_translation_table (int cpsource, in
iconv_t cd;
const char *cpsour, *cpdisp;
+ cpsour = get_codepage_id (cpsource);
+ cpdisp = get_codepage_id (cpdisplay);
+
+ if ((cpsour == NULL) || (cpdisp == NULL)) {
+ g_snprintf (errbuf, sizeof (errbuf), _("Cannot get correct codepage id"));
+ return errbuf;
+ }
+
/* Fill inpit <-> display tables */
- if (cpsource < 0 || cpdisplay < 0 || cpsource == cpdisplay) {
+ if ((strcasecmp(cpsour, cpdisp) == 0) || cpsource == cpdisplay) {
for (i = 0; i <= 255; ++i) {
conv_displ[i] = i;
conv_input[i] = i;
@@ -187,9 +215,6 @@ init_translation_table (int cpsource, in
conv_input[i] = i;
}
- cpsour = codepages[cpsource].id;
- cpdisp = codepages[cpdisplay].id;
-
/* display <- inpit table */
cd = iconv_open (cpdisp, cpsour);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]