1 /* Character set conversion support for GDB.
2 Copyright 2001 Free Software Foundation, Inc.
4 This file is part of GDB.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
24 #include "gdb_assert.h"
35 /* How GDB's character set support works
37 GDB has two global settings:
39 - The `current host character set' is the character set GDB should
40 use in talking to the user, and which (hopefully) the user's
41 terminal knows how to display properly.
43 - The `current target character set' is the character set the
44 program being debugged uses.
46 There are commands to set each of these, and mechanisms for
47 choosing reasonable default values. GDB has a global list of
48 character sets that it can use as its host or target character
51 The header file `charset.h' declares various functions that
52 different pieces of GDB need to perform tasks like:
54 - printing target strings and characters to the user's terminal
55 (mostly target->host conversions),
57 - building target-appropriate representations of strings and
58 characters the user enters in expressions (mostly host->target
63 Now, many of these operations are specific to a particular
64 host/target character set pair. If GDB supports N character sets,
65 there are N^2 possible pairs. This means that, the larger GDB's
66 repertoire of character sets gets, the more expensive it gets to add
69 To make sure that GDB can do the right thing for every possible
70 pairing of host and target character set, while still allowing
71 GDB's repertoire to scale, we use a two-tiered approach:
73 - We maintain a global table of "translations" --- groups of
74 functions specific to a particular pair of character sets.
76 - However, a translation can be incomplete: some functions can be
77 omitted. Where there is not a translation to specify exactly
78 what function to use, we provide reasonable defaults. The
79 default behaviors try to use the "iconv" library functions, which
80 support a wide range of character sets. However, even if iconv
81 is not available, there are fallbacks to support trivial
82 translations: when the host and target character sets are the
86 /* The character set and translation structures. */
89 /* A character set GDB knows about. GDB only supports character sets
90 with stateless encodings, in which every character is one byte
94 /* A singly-linked list of all known charsets. */
97 /* The name of the character set. Comparisons on character set
98 names are case-insensitive. */
101 /* Non-zero iff this character set can be used as a host character
102 set. At present, GDB basically assumes that the host character
103 set is a superset of ASCII. */
104 int valid_host_charset;
106 /* Pointers to charset-specific functions that depend only on a
107 single character set, and data pointers to pass to them. */
108 int (*host_char_print_literally) (void *baton,
110 void *host_char_print_literally_baton;
112 int (*target_char_to_control_char) (void *baton,
114 int *target_ctrl_char);
115 void *target_char_to_control_char_baton;
119 /* A translation from one character set to another. */
122 /* A singly-linked list of all known translations. */
123 struct translation *next;
125 /* This structure describes functions going from the FROM character
126 set to the TO character set. Comparisons on character set names
127 are case-insensitive. */
128 const char *from, *to;
130 /* Pointers to translation-specific functions, and data pointers to
131 pass to them. These pointers can be zero, indicating that GDB
132 should fall back on the default behavior. We hope the default
133 behavior will be correct for many from/to pairs, reducing the
134 number of translations that need to be registered explicitly. */
136 /* TARGET_CHAR is in the `from' charset.
137 Returns a string in the `to' charset. */
138 const char *(*c_target_char_has_backslash_escape) (void *baton,
140 void *c_target_char_has_backslash_escape_baton;
142 /* HOST_CHAR is in the `from' charset.
143 TARGET_CHAR points to a char in the `to' charset. */
144 int (*c_parse_backslash) (void *baton, int host_char, int *target_char);
145 void *c_parse_backslash_baton;
147 /* This is used for the host_char_to_target and target_char_to_host
149 int (*convert_char) (void *baton, int from, int *to);
150 void *convert_char_baton;
155 /* The global lists of character sets and translations. */
158 /* Character set names are always compared ignoring case. */
160 strcmp_case_insensitive (const char *p, const char *q)
162 while (*p && *q && tolower (*p) == tolower (*q))
165 return tolower (*p) - tolower (*q);
169 /* The global list of all the charsets GDB knows about. */
170 static struct charset *all_charsets;
174 register_charset (struct charset *cs)
176 struct charset **ptr;
178 /* Put the new charset on the end, so that the list ends up in the
179 same order as the registrations in the _initialize function. */
180 for (ptr = &all_charsets; *ptr; ptr = &(*ptr)->next)
188 static struct charset *
189 lookup_charset (const char *name)
193 for (cs = all_charsets; cs; cs = cs->next)
194 if (! strcmp_case_insensitive (name, cs->name))
201 /* The global list of translations. */
202 static struct translation *all_translations;
206 register_translation (struct translation *t)
208 t->next = all_translations;
209 all_translations = t;
213 static struct translation *
214 lookup_translation (const char *from, const char *to)
216 struct translation *t;
218 for (t = all_translations; t; t = t->next)
219 if (! strcmp_case_insensitive (from, t->from)
220 && ! strcmp_case_insensitive (to, t->to))
228 /* Constructing charsets. */
230 /* Allocate, initialize and return a straightforward charset.
231 Use this function, rather than creating the structures yourself,
232 so that we can add new fields to the structure in the future without
233 having to tweak all the old charset descriptions. */
234 static struct charset *
235 simple_charset (const char *name,
236 int valid_host_charset,
237 int (*host_char_print_literally) (void *baton, int host_char),
238 void *host_char_print_literally_baton,
239 int (*target_char_to_control_char) (void *baton,
241 int *target_ctrl_char),
242 void *target_char_to_control_char_baton)
244 struct charset *cs = xmalloc (sizeof (*cs));
246 memset (cs, 0, sizeof (*cs));
248 cs->valid_host_charset = valid_host_charset;
249 cs->host_char_print_literally = host_char_print_literally;
250 cs->host_char_print_literally_baton = host_char_print_literally_baton;
251 cs->target_char_to_control_char = target_char_to_control_char;
252 cs->target_char_to_control_char_baton = target_char_to_control_char_baton;
259 /* ASCII functions. */
262 ascii_print_literally (void *baton, int c)
266 return (0x20 <= c && c <= 0x7e);
271 ascii_to_control (void *baton, int c, int *ctrl_char)
273 *ctrl_char = (c & 037);
278 /* ISO-8859 family functions. */
282 iso_8859_print_literally (void *baton, int c)
286 return ((0x20 <= c && c <= 0x7e) /* ascii printables */
287 || (! sevenbit_strings && 0xA0 <= c)); /* iso 8859 printables */
292 iso_8859_to_control (void *baton, int c, int *ctrl_char)
294 *ctrl_char = (c & 0200) | (c & 037);
299 /* Construct an ISO-8859-like character set. */
300 static struct charset *
301 iso_8859_family_charset (const char *name)
303 return simple_charset (name, 1,
304 iso_8859_print_literally, 0,
305 iso_8859_to_control, 0);
310 /* EBCDIC family functions. */
314 ebcdic_print_literally (void *baton, int c)
318 return (64 <= c && c <= 254);
323 ebcdic_to_control (void *baton, int c, int *ctrl_char)
325 /* There are no control character equivalents in EBCDIC. Use
331 /* Construct an EBCDIC-like character set. */
332 static struct charset *
333 ebcdic_family_charset (const char *name)
335 return simple_charset (name, 0,
336 ebcdic_print_literally, 0,
337 ebcdic_to_control, 0);
344 /* Fallback functions using iconv. */
346 #if defined(HAVE_ICONV)
348 struct cached_iconv {
349 struct charset *from, *to;
354 /* Make sure the iconv cache *CI contains an iconv descriptor
355 translating from FROM to TO. If it already does, fine; otherwise,
356 close any existing descriptor, and open up a new one. On success,
357 return zero; on failure, return -1 and set errno. */
359 check_iconv_cache (struct cached_iconv *ci,
360 struct charset *from,
365 /* Does the cached iconv descriptor match the conversion we're trying
369 && ci->i != (iconv_t) 0)
372 /* It doesn't. If we actually had any iconv descriptor open at
373 all, close it now. */
374 if (ci->i != (iconv_t) 0)
379 if (iconv_close (i) == -1)
380 error ("Error closing `iconv' descriptor for "
381 "`%s'-to-`%s' character conversion: %s",
382 ci->from->name, ci->to->name, safe_strerror (errno));
385 /* Open a new iconv descriptor for the required conversion. */
386 i = iconv_open (to->name, from->name);
387 if (i == (iconv_t) -1)
398 /* Convert FROM_CHAR using the cached iconv conversion *CI. Return
399 non-zero if the conversion was successful, zero otherwise. */
401 cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
404 ICONV_CONST char *from_ptr = &from;
405 char to, *to_ptr = &to;
406 size_t from_left = sizeof (from), to_left = sizeof (to);
408 gdb_assert (ci->i != (iconv_t) 0);
411 if (iconv (ci->i, &from_ptr, &from_left, &to_ptr, &to_left)
414 /* These all suggest that the input or output character sets
415 have multi-byte encodings of some characters, which means
416 it's unsuitable for use as a GDB character set. We should
417 never have selected it. */
418 gdb_assert (errno != E2BIG && errno != EINVAL);
420 /* This suggests a bug in the code managing *CI. */
421 gdb_assert (errno != EBADF);
423 /* This seems to mean that there is no equivalent character in
424 the `to' character set. */
428 /* Anything else is mysterious. */
429 internal_error ("Error converting character `%d' from `%s' to `%s' "
431 from_char, ci->from->name, ci->to->name,
432 safe_strerror (errno));
435 /* If the pointers weren't advanced across the input, that also
436 suggests something was wrong. */
437 gdb_assert (from_left == 0 && to_left == 0);
439 *to_char = (unsigned char) to;
445 register_iconv_charsets ()
447 /* Here we should check whether various character sets were
448 recognized by the local iconv implementation.
450 The first implementation registered a bunch of character sets
451 recognized by iconv, but then we discovered that iconv on Solaris
452 and iconv on GNU/Linux had no character sets in common. So we
453 replaced them with the hard-coded tables that appear later in the
457 #endif /* defined (HAVE_ICONV) */
460 /* Fallback routines for systems without iconv. */
462 #if ! defined (HAVE_ICONV)
463 struct cached_iconv { char nothing; };
466 check_iconv_cache (struct cached_iconv *ci,
467 struct charset *from,
475 cached_iconv_convert (struct cached_iconv *ci, int from_char, int *to_char)
477 /* This function should never be called. */
482 register_iconv_charsets ()
486 #endif /* ! defined(HAVE_ICONV) */
489 /* Default trivial conversion functions. */
492 identity_either_char_to_other (void *baton, int either_char, int *other_char)
494 *other_char = either_char;
500 /* Default non-trivial conversion functions. */
503 static char backslashable[] = "abefnrtv";
504 static char *backslashed[] = {"a", "b", "e", "f", "n", "r", "t", "v", "0"};
505 static char represented[] = "\a\b\e\f\n\r\t\v";
508 /* Translate TARGET_CHAR into the host character set, and see if it
509 matches any of our standard escape sequences. */
511 default_c_target_char_has_backslash_escape (void *baton, int target_char)
516 /* If target_char has no equivalent in the host character set,
517 assume it doesn't have a backslashed form. */
518 if (! target_char_to_host (target_char, &host_char))
521 ix = strchr (represented, host_char);
523 return backslashed[ix - represented];
529 /* Translate the backslash the way we would in the host character set,
530 and then try to translate that into the target character set. */
532 default_c_parse_backslash (void *baton, int host_char, int *target_char)
536 ix = strchr (backslashable, host_char);
541 return host_char_to_target (represented[ix - backslashable],
546 /* Convert using a cached iconv descriptor. */
548 iconv_convert (void *baton, int from_char, int *to_char)
550 struct cached_iconv *ci = baton;
551 return cached_iconv_convert (ci, from_char, to_char);
556 /* Conversion tables. */
559 /* I'd much rather fall back on iconv whenever possible. But the
560 character set names you use with iconv aren't standardized at all,
561 a lot of platforms have really meager character set coverage, etc.
562 I wanted to have at least something we could use to exercise the
563 test suite on all platforms.
565 In the long run, we should have a configure-time process explore
566 somehow which character sets the host platform supports, and some
567 arrangement that allows GDB users to use platform-indepedent names
568 for character sets. */
571 /* We generated these tables using iconv on a GNU/Linux machine. */
574 static int ascii_to_iso_8859_1_table[] = {
575 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
576 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
577 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
578 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
579 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
580 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
581 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
582 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
583 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
584 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
585 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
586 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
587 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
588 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
589 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
590 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
594 static int ascii_to_ebcdic_us_table[] = {
595 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
596 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
597 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
598 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
599 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
600 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
601 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
602 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
603 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
604 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
605 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
606 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
607 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
608 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
609 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
610 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
614 static int ascii_to_ibm1047_table[] = {
615 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
616 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
617 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
618 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
619 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
620 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
621 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
622 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
623 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
624 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
625 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
626 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
627 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
628 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
629 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
630 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
634 static int iso_8859_1_to_ascii_table[] = {
635 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
636 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
637 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
638 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
639 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, /* 80 */
640 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, /* 96 */
641 96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111, /* 112 */
642 112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127, /* 128 */
643 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 144 */
644 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 160 */
645 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 176 */
646 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
647 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
648 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
649 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
650 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
654 static int iso_8859_1_to_ebcdic_us_table[] = {
655 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
656 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
657 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
658 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
659 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
660 215,216,217,226,227,228,229,230,231,232,233, -1,224, -1, -1,109, /* 96 */
661 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
662 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
663 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
664 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
665 -1, -1, 74, -1, -1, -1,106, -1, -1, -1, -1, -1, 95, -1, -1, -1, /* 176 */
666 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
667 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 208 */
668 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 224 */
669 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 240 */
670 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 /* 256 */
674 static int iso_8859_1_to_ibm1047_table[] = {
675 0, 1, 2, 3, 55, 45, 46, 47, 22, 5, 37, 11, 12, 13, 14, 15, /* 16 */
676 16, 17, 18, 19, 60, 61, 50, 38, 24, 25, 63, 39, 28, 29, 30, 31, /* 32 */
677 64, 90,127,123, 91,108, 80,125, 77, 93, 92, 78,107, 96, 75, 97, /* 48 */
678 240,241,242,243,244,245,246,247,248,249,122, 94, 76,126,110,111, /* 64 */
679 124,193,194,195,196,197,198,199,200,201,209,210,211,212,213,214, /* 80 */
680 215,216,217,226,227,228,229,230,231,232,233,173,224,189, 95,109, /* 96 */
681 121,129,130,131,132,133,134,135,136,137,145,146,147,148,149,150, /* 112 */
682 151,152,153,162,163,164,165,166,167,168,169,192, 79,208,161, 7, /* 128 */
683 32, 33, 34, 35, 36, 21, 6, 23, 40, 41, 42, 43, 44, 9, 10, 27, /* 144 */
684 48, 49, 26, 51, 52, 53, 54, 8, 56, 57, 58, 59, 4, 20, 62,255, /* 160 */
685 65,170, 74,177,159,178,106,181,187,180,154,138,176,202,175,188, /* 176 */
686 144,143,234,250,190,160,182,179,157,218,155,139,183,184,185,171, /* 192 */
687 100,101, 98,102, 99,103,158,104,116,113,114,115,120,117,118,119, /* 208 */
688 172,105,237,238,235,239,236,191,128,253,254,251,252,186,174, 89, /* 224 */
689 68, 69, 66, 70, 67, 71,156, 72, 84, 81, 82, 83, 88, 85, 86, 87, /* 240 */
690 140, 73,205,206,203,207,204,225,112,221,222,219,220,141,142,223 /* 256 */
694 static int ebcdic_us_to_ascii_table[] = {
695 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
696 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
697 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
698 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
699 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
700 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, -1, /* 96 */
701 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
702 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
703 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
704 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
705 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
706 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
707 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
708 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
709 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
710 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
714 static int ebcdic_us_to_iso_8859_1_table[] = {
715 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
716 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
717 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
718 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
719 32, -1, -1, -1, -1, -1, -1, -1, -1, -1,162, 46, 60, 40, 43,124, /* 80 */
720 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59,172, /* 96 */
721 45, 47, -1, -1, -1, -1, -1, -1, -1, -1,166, 44, 37, 95, 62, 63, /* 112 */
722 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
723 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
724 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
725 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, -1, -1, -1, /* 176 */
726 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
727 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
728 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
729 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
730 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1,159 /* 256 */
734 static int ebcdic_us_to_ibm1047_table[] = {
735 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
736 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
737 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
738 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
739 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
740 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94,176, /* 96 */
741 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
742 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
743 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
744 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
745 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
746 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
747 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
748 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
749 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
750 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
754 static int ibm1047_to_ascii_table[] = {
755 0, 1, 2, 3, -1, 9, -1,127, -1, -1, -1, 11, 12, 13, 14, 15, /* 16 */
756 16, 17, 18, 19, -1, -1, 8, -1, 24, 25, -1, -1, 28, 29, 30, 31, /* 32 */
757 -1, -1, -1, -1, -1, 10, 23, 27, -1, -1, -1, -1, -1, 5, 6, 7, /* 48 */
758 -1, -1, 22, -1, -1, -1, -1, 4, -1, -1, -1, -1, 20, 21, -1, 26, /* 64 */
759 32, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 46, 60, 40, 43,124, /* 80 */
760 38, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 36, 42, 41, 59, 94, /* 96 */
761 45, 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, 44, 37, 95, 62, 63, /* 112 */
762 -1, -1, -1, -1, -1, -1, -1, -1, -1, 96, 58, 35, 64, 39, 61, 34, /* 128 */
763 -1, 97, 98, 99,100,101,102,103,104,105, -1, -1, -1, -1, -1, -1, /* 144 */
764 -1,106,107,108,109,110,111,112,113,114, -1, -1, -1, -1, -1, -1, /* 160 */
765 -1,126,115,116,117,118,119,120,121,122, -1, -1, -1, 91, -1, -1, /* 176 */
766 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 93, -1, -1, /* 192 */
767 123, 65, 66, 67, 68, 69, 70, 71, 72, 73, -1, -1, -1, -1, -1, -1, /* 208 */
768 125, 74, 75, 76, 77, 78, 79, 80, 81, 82, -1, -1, -1, -1, -1, -1, /* 224 */
769 92, -1, 83, 84, 85, 86, 87, 88, 89, 90, -1, -1, -1, -1, -1, -1, /* 240 */
770 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, -1, -1, -1, -1, -1, -1 /* 256 */
774 static int ibm1047_to_iso_8859_1_table[] = {
775 0, 1, 2, 3,156, 9,134,127,151,141,142, 11, 12, 13, 14, 15, /* 16 */
776 16, 17, 18, 19,157,133, 8,135, 24, 25,146,143, 28, 29, 30, 31, /* 32 */
777 128,129,130,131,132, 10, 23, 27,136,137,138,139,140, 5, 6, 7, /* 48 */
778 144,145, 22,147,148,149,150, 4,152,153,154,155, 20, 21,158, 26, /* 64 */
779 32,160,226,228,224,225,227,229,231,241,162, 46, 60, 40, 43,124, /* 80 */
780 38,233,234,235,232,237,238,239,236,223, 33, 36, 42, 41, 59, 94, /* 96 */
781 45, 47,194,196,192,193,195,197,199,209,166, 44, 37, 95, 62, 63, /* 112 */
782 248,201,202,203,200,205,206,207,204, 96, 58, 35, 64, 39, 61, 34, /* 128 */
783 216, 97, 98, 99,100,101,102,103,104,105,171,187,240,253,254,177, /* 144 */
784 176,106,107,108,109,110,111,112,113,114,170,186,230,184,198,164, /* 160 */
785 181,126,115,116,117,118,119,120,121,122,161,191,208, 91,222,174, /* 176 */
786 172,163,165,183,169,167,182,188,189,190,221,168,175, 93,180,215, /* 192 */
787 123, 65, 66, 67, 68, 69, 70, 71, 72, 73,173,244,246,242,243,245, /* 208 */
788 125, 74, 75, 76, 77, 78, 79, 80, 81, 82,185,251,252,249,250,255, /* 224 */
789 92,247, 83, 84, 85, 86, 87, 88, 89, 90,178,212,214,210,211,213, /* 240 */
790 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,179,219,220,217,218,159 /* 256 */
794 static int ibm1047_to_ebcdic_us_table[] = {
795 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* 16 */
796 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, /* 32 */
797 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, /* 48 */
798 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, /* 64 */
799 64, -1, -1, -1, -1, -1, -1, -1, -1, -1, 74, 75, 76, 77, 78, 79, /* 80 */
800 80, -1, -1, -1, -1, -1, -1, -1, -1, -1, 90, 91, 92, 93, 94, -1, /* 96 */
801 96, 97, -1, -1, -1, -1, -1, -1, -1, -1,106,107,108,109,110,111, /* 112 */
802 -1, -1, -1, -1, -1, -1, -1, -1, -1,121,122,123,124,125,126,127, /* 128 */
803 -1,129,130,131,132,133,134,135,136,137, -1, -1, -1, -1, -1, -1, /* 144 */
804 -1,145,146,147,148,149,150,151,152,153, -1, -1, -1, -1, -1, -1, /* 160 */
805 -1,161,162,163,164,165,166,167,168,169, -1, -1, -1, -1, -1, -1, /* 176 */
806 95, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 192 */
807 192,193,194,195,196,197,198,199,200,201, -1, -1, -1, -1, -1, -1, /* 208 */
808 208,209,210,211,212,213,214,215,216,217, -1, -1, -1, -1, -1, -1, /* 224 */
809 224, -1,226,227,228,229,230,231,232,233, -1, -1, -1, -1, -1, -1, /* 240 */
810 240,241,242,243,244,245,246,247,248,249, -1, -1, -1, -1, -1,255 /* 256 */
815 table_convert_char (void *baton, int from, int *to)
817 int *table = (int *) baton;
819 if (0 <= from && from <= 255
820 && table[from] != -1)
830 static struct translation *
831 table_translation (const char *from, const char *to, int *table,
832 const char *(*c_target_char_has_backslash_escape)
833 (void *baton, int target_char),
834 void *c_target_char_has_backslash_escape_baton,
835 int (*c_parse_backslash) (void *baton,
838 void *c_parse_backslash_baton)
840 struct translation *t = xmalloc (sizeof (*t));
842 memset (t, 0, sizeof (*t));
845 t->c_target_char_has_backslash_escape = c_target_char_has_backslash_escape;
846 t->c_target_char_has_backslash_escape_baton
847 = c_target_char_has_backslash_escape_baton;
848 t->c_parse_backslash = c_parse_backslash;
849 t->c_parse_backslash_baton = c_parse_backslash_baton;
850 t->convert_char = table_convert_char;
851 t->convert_char_baton = (void *) table;
857 static struct translation *
858 simple_table_translation (const char *from, const char *to, int *table)
860 return table_translation (from, to, table, 0, 0, 0, 0);
865 /* Setting and retrieving the host and target charsets. */
868 /* The current host and target character sets. */
869 static struct charset *current_host_charset, *current_target_charset;
871 /* The current functions and batons we should use for the functions in
874 static const char *(*c_target_char_has_backslash_escape_func)
875 (void *baton, int target_char);
876 static void *c_target_char_has_backslash_escape_baton;
878 static int (*c_parse_backslash_func) (void *baton,
881 static void *c_parse_backslash_baton;
883 static int (*host_char_to_target_func) (void *baton,
886 static void *host_char_to_target_baton;
888 static int (*target_char_to_host_func) (void *baton,
891 static void *target_char_to_host_baton;
894 /* Cached iconv conversions, that might be useful to fallback
896 static struct cached_iconv cached_iconv_host_to_target;
897 static struct cached_iconv cached_iconv_target_to_host;
900 /* Set the host and target character sets to HOST and TARGET. */
902 set_host_and_target_charsets (struct charset *host, struct charset *target)
904 struct translation *h2t, *t2h;
906 /* If they're not both initialized yet, then just do nothing for
907 now. As soon as we're done running our initialize function,
908 everything will be initialized. */
909 if (! host || ! target)
911 current_host_charset = host;
912 current_target_charset = target;
916 h2t = lookup_translation (host->name, target->name);
917 t2h = lookup_translation (target->name, host->name);
919 /* If the translations don't provide conversion functions, make sure
920 iconv can back them up. Do this *before* modifying any state. */
923 if (! h2t || ! h2t->convert_char)
925 if (check_iconv_cache (&cached_iconv_host_to_target, host, target)
927 error ("GDB can't convert from the `%s' character set to `%s'.",
928 host->name, target->name);
930 if (! t2h || ! t2h->convert_char)
932 if (check_iconv_cache (&cached_iconv_target_to_host, target, host)
934 error ("GDB can't convert from the `%s' character set to `%s'.",
935 target->name, host->name);
939 if (t2h && t2h->c_target_char_has_backslash_escape)
941 c_target_char_has_backslash_escape_func
942 = t2h->c_target_char_has_backslash_escape;
943 c_target_char_has_backslash_escape_baton
944 = t2h->c_target_char_has_backslash_escape_baton;
947 c_target_char_has_backslash_escape_func
948 = default_c_target_char_has_backslash_escape;
950 if (h2t && h2t->c_parse_backslash)
952 c_parse_backslash_func = h2t->c_parse_backslash;
953 c_parse_backslash_baton = h2t->c_parse_backslash_baton;
956 c_parse_backslash_func = default_c_parse_backslash;
958 if (h2t && h2t->convert_char)
960 host_char_to_target_func = h2t->convert_char;
961 host_char_to_target_baton = h2t->convert_char_baton;
963 else if (host == target)
964 host_char_to_target_func = identity_either_char_to_other;
967 host_char_to_target_func = iconv_convert;
968 host_char_to_target_baton = &cached_iconv_host_to_target;
971 if (t2h && t2h->convert_char)
973 target_char_to_host_func = t2h->convert_char;
974 target_char_to_host_baton = t2h->convert_char_baton;
976 else if (host == target)
977 target_char_to_host_func = identity_either_char_to_other;
980 target_char_to_host_func = iconv_convert;
981 target_char_to_host_baton = &cached_iconv_target_to_host;
984 current_host_charset = host;
985 current_target_charset = target;
989 static struct charset *
990 lookup_charset_or_error (const char *name)
992 struct charset *cs = lookup_charset (name);
995 error ("GDB doesn't know of any character set named `%s'.", name);
1002 check_valid_host_charset (struct charset *cs)
1004 if (! cs->valid_host_charset)
1005 error ("GDB can't use `%s' as its host character set.", cs->name);
1010 set_host_charset (const char *charset)
1012 struct charset *cs = lookup_charset_or_error (charset);
1013 check_valid_host_charset (cs);
1014 set_host_and_target_charsets (cs, current_target_charset);
1021 return current_host_charset->name;
1026 set_target_charset (const char *charset)
1028 struct charset *cs = lookup_charset_or_error (charset);
1030 set_host_and_target_charsets (current_host_charset, cs);
1037 return current_target_charset->name;
1042 /* Public character management functions. */
1046 c_target_char_has_backslash_escape (int target_char)
1048 return ((*c_target_char_has_backslash_escape_func)
1049 (c_target_char_has_backslash_escape_baton, target_char));
1054 c_parse_backslash (int host_char, int *target_char)
1056 return (*c_parse_backslash_func) (c_parse_backslash_baton,
1057 host_char, target_char);
1062 host_char_print_literally (int host_char)
1064 return ((*current_host_charset->host_char_print_literally)
1065 (current_host_charset->host_char_print_literally_baton,
1071 target_char_to_control_char (int target_char, int *target_ctrl_char)
1073 return ((*current_target_charset->target_char_to_control_char)
1074 (current_target_charset->target_char_to_control_char_baton,
1075 target_char, target_ctrl_char));
1080 host_char_to_target (int host_char, int *target_char)
1082 return ((*host_char_to_target_func)
1083 (host_char_to_target_baton, host_char, target_char));
1088 target_char_to_host (int target_char, int *host_char)
1090 return ((*target_char_to_host_func)
1091 (target_char_to_host_baton, target_char, host_char));
1099 /* List the valid character sets. If HOST_ONLY is non-zero, list only
1100 those character sets which can be used as GDB's host character set. */
1102 list_charsets (int host_only)
1106 printf_filtered ("Valid character sets are:\n");
1108 for (cs = all_charsets; cs; cs = cs->next)
1109 if (host_only && cs->valid_host_charset)
1110 printf_filtered (" %s\n", cs->name);
1112 printf_filtered (" %s %s\n",
1114 cs->valid_host_charset ? "*" : " ");
1117 printf_filtered ("* - can be used as a host character set\n");
1122 set_charset_command (char *arg, int from_tty)
1124 if (! arg || arg[0] == '\0')
1128 struct charset *cs = lookup_charset_or_error (arg);
1129 check_valid_host_charset (cs);
1130 set_host_and_target_charsets (cs, cs);
1136 set_host_charset_command (char *arg, int from_tty)
1138 if (! arg || arg[0] == '\0')
1142 struct charset *cs = lookup_charset_or_error (arg);
1143 check_valid_host_charset (cs);
1144 set_host_and_target_charsets (cs, current_target_charset);
1150 set_target_charset_command (char *arg, int from_tty)
1152 if (! arg || arg[0] == '\0')
1156 struct charset *cs = lookup_charset_or_error (arg);
1157 set_host_and_target_charsets (current_host_charset, cs);
1163 show_charset_command (char *arg, int from_tty)
1165 if (current_host_charset == current_target_charset)
1167 printf_filtered ("The current host and target character set is `%s'.\n",
1172 printf_filtered ("The current host character set is `%s'.\n",
1174 printf_filtered ("The current target character set is `%s'.\n",
1181 /* The charset.c module initialization function. */
1183 #ifndef GDB_DEFAULT_HOST_CHARSET
1184 #define GDB_DEFAULT_HOST_CHARSET "ISO-8859-1"
1187 #ifndef GDB_DEFAULT_TARGET_CHARSET
1188 #define GDB_DEFAULT_TARGET_CHARSET "ISO-8859-1"
1192 _initialize_charset (void)
1194 /* Register all the character set GDB knows about.
1196 You should use the same names that iconv does, where possible, to
1197 take advantage of the iconv-based default behaviors.
1199 CAUTION: if you register a character set, you must also register
1200 as many translations as are necessary to make that character set
1201 interoperate correctly with all the other character sets. We do
1202 provide default behaviors when no translation is available, or
1203 when a translation's function pointer for a particular operation
1204 is zero. Hopefully, these defaults will be correct often enough
1205 that we won't need to provide too many translations. */
1206 register_charset (simple_charset ("ascii", 1,
1207 ascii_print_literally, 0,
1208 ascii_to_control, 0));
1209 register_charset (iso_8859_family_charset ("iso-8859-1"));
1210 register_charset (ebcdic_family_charset ("ebcdic-us"));
1211 register_charset (ebcdic_family_charset ("ibm1047"));
1212 register_iconv_charsets ();
1215 struct { char *from; char *to; int *table; } tlist[] = {
1216 { "ascii", "iso-8859-1", ascii_to_iso_8859_1_table },
1217 { "ascii", "ebcdic-us", ascii_to_ebcdic_us_table },
1218 { "ascii", "ibm1047", ascii_to_ibm1047_table },
1219 { "iso-8859-1", "ascii", iso_8859_1_to_ascii_table },
1220 { "iso-8859-1", "ebcdic-us", iso_8859_1_to_ebcdic_us_table },
1221 { "iso-8859-1", "ibm1047", iso_8859_1_to_ibm1047_table },
1222 { "ebcdic-us", "ascii", ebcdic_us_to_ascii_table },
1223 { "ebcdic-us", "iso-8859-1", ebcdic_us_to_iso_8859_1_table },
1224 { "ebcdic-us", "ibm1047", ebcdic_us_to_ibm1047_table },
1225 { "ibm1047", "ascii", ibm1047_to_ascii_table },
1226 { "ibm1047", "iso-8859-1", ibm1047_to_iso_8859_1_table },
1227 { "ibm1047", "ebcdic-us", ibm1047_to_ebcdic_us_table }
1232 for (i = 0; i < (sizeof (tlist) / sizeof (tlist[0])); i++)
1233 register_translation (simple_table_translation (tlist[i].from,
1238 set_host_charset (GDB_DEFAULT_HOST_CHARSET);
1239 set_target_charset (GDB_DEFAULT_TARGET_CHARSET);
1241 add_cmd ("charset", class_support, set_charset_command,
1242 "Use CHARSET as the host and target character set.\n"
1243 "The `host character set' is the one used by the system GDB is running on.\n"
1244 "The `target character set' is the one used by the program being debugged.\n"
1245 "You may only use supersets of ASCII for your host character set; GDB does\n"
1246 "not support any others.\n"
1247 "To see a list of the character sets GDB supports, type `set charset'\n"
1248 "with no argument.",
1251 add_cmd ("host-charset", class_support, set_host_charset_command,
1252 "Use CHARSET as the host character set.\n"
1253 "The `host character set' is the one used by the system GDB is running on.\n"
1254 "You may only use supersets of ASCII for your host character set; GDB does\n"
1255 "not support any others.\n"
1256 "To see a list of the character sets GDB supports, type `set host-charset'\n"
1257 "with no argument.",
1260 add_cmd ("target-charset", class_support, set_target_charset_command,
1261 "Use CHARSET as the target character set.\n"
1262 "The `target character set' is the one used by the program being debugged.\n"
1263 "GDB translates characters and strings between the host and target\n"
1264 "character sets as needed.\n"
1265 "To see a list of the character sets GDB supports, type `set target-charset'\n"
1266 "with no argument.",
1269 add_cmd ("charset", class_support, show_charset_command,
1270 "Show the current host and target character sets.",
1272 add_alias_cmd ("host-charset", "charset", class_alias, 1, &showlist);
1273 add_alias_cmd ("target-charset", "charset", class_alias, 1, &showlist);