Re: [RFA] defs.h: Define GDB_DEFAULT_TARGET_[WIDE_]CHARSET for Cygwin and MingW builds

Corinna Vinschen
2010-02-28T18:11:12Z

On Feb 28 18:52, Corinna Vinschen wrote:
> On Feb 28 19:45, Eli Zaretskii wrote:
> > > Date: Sun, 28 Feb 2010 18:05:23 +0100
> > > From: Corinna Vinschen <vinschen@redhat.com>
> > >
> > > > > +#define GDB_DEFAULT_TARGET_CHARSET "CP1252"
> > > > > +#endif
> > > >
> > > > Why cp1252? why not detect the ANSI codepage at run time, and make
> > > > more non-Latin users happy?
> > >
> > > How? Is there somewhere a function which converts a Windows codepage
> > > number into a iconv compatible codeset string?
> >
> > Sorry, I'm not following: last time I looked, iconv supported cpNNNN
> > codepages out of the box. This is from an Ubuntu GNU/Linux system:
> >
> > $ iconv --version
> > iconv (GNU libiconv 1.11)
> > $ iconv --list | egrep "^CP"
> > CP819 IBM819 ISO-8859-1 ISO-IR-100 ISO8859-1 ISO_8859-1 ISO_8859-1:1987 L1 LATIN1 CSISOLATIN1
> > CP1250 MS-EE WINDOWS-1250
> > CP1251 MS-CYRL WINDOWS-1251
> > CP1252 MS-ANSI WINDOWS-1252
> > CP1253 MS-GREEK WINDOWS-1253
> > CP1254 MS-TURK WINDOWS-1254
> > CP1255 MS-HEBR WINDOWS-1255
> > CP1256 MS-ARAB WINDOWS-1256
> > CP1257 WINBALTRIM WINDOWS-1257
> > CP1258 WINDOWS-1258
> > CP154 CYRILLIC-ASIAN PT154 PTCP154 CSPTCP154
> > CP1133 IBM-CP1133
> > CP874 WINDOWS-874
> > CP932
> > CP936 MS936 WINDOWS-936
> > CP950
> > CP949 UHC
> > CP1361 JOHAB
> >
> > What am I missing?
>
> Windows has a function GetACP() which returns the current ANSI
> codepage. iconv wants a string which determines the source and
> target codesets. I don't know any function in Windows which
> converts a codepage number into an iconv-compatible codeset name.

Erm. Looks I wasn't thinking at all. Since every codepage seems
to be simply avaiable as "CPxxx", it can be easily constructed,
apparently.

So this:

#define GDB_DEFAULT_TARGET_CHARSET get_cp()

char *
get_cp ()
{
char buf[32];

snprintf (buf, 32, "CP%u", GetACP ());
}

should do it, right?

Corinna

--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat