delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2009/06/19/22:02:49

X-Authentication-Warning: delorie.com: mail set sender to djgpp-workers-bounces using -f
X-Recipient: djgpp-workers AT delorie DOT com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=gamma;
h=domainkey-signature:mime-version:received:in-reply-to:references
:date:message-id:subject:from:to:content-type
:content-transfer-encoding;
bh=nYwUZxButWXyId6efnygwO6cKmgNpCJLBKl41V1Eqp8=;
b=VfIehnO5lODfSi6r8SfknfrCfgJckI86gttXAtrZnacb8eqMesOpmem3sclf6hMI/D
dCLpjeoqhMoZh3tW2+bPhFS+cR/1EaMtAA5Dum6/OqyWoRtJFCHb9dqOA8P+dY6iZdxg
PIgS4aSUixvT9wMtFJwg4hDEKbqgPxB+kBWHs=
DomainKey-Signature: a=rsa-sha1; c=nofws;
d=gmail.com; s=gamma;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type:content-transfer-encoding;
b=Zw++mbSuCPqfVWD3EmuU8CKtmstwdM/b2jVfHYkezZ8FaukmukUgvVaJNG4F3vyeqZ
C+arKFzFB4Pi2CaWj3IMn12p6rC03PpR43iYaJrSqmx011Mdw1rWvoUfiOsA8Ya3sOvf
N6NyHuocZ865Ewvx13lisKS1Pmsd6tHrp2eT8=
MIME-Version: 1.0
In-Reply-To: <93c172b50905051028n3be290aar8c80440870ee6101@mail.gmail.com>
References: <93c172b50905051028n3be290aar8c80440870ee6101 AT mail DOT gmail DOT com>
Date: Fri, 19 Jun 2009 15:41:06 -0500
Message-ID: <93c172b50906191341t4f88976if685586c0918d6e3@mail.gmail.com>
Subject: Fwd: query con codepage
From: Rugxulo <rugxulo AT gmail DOT com>
To: djgpp-workers AT delorie DOT com
Reply-To: djgpp-workers AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

I'm honestly not sure if this is the right place to mention this since
it's not "core" functionality, but maybe somebody finds it useful.


---------- Forwarded message ----------
From: Rugxulo <rugxulo AT gmail DOT com>
Date: Tue, May 5, 2009 at 12:28 PM
Subject: query con codepage


Okay, so here's my DJGPP version of the "query con codepage" function.
Feel free to use it (or ignore), whatever. =A0 =A0;-)

#include <dpmi.h>
#include <go32.h>
#include <stdio.h>

// ----------------------------------------------------------------------
// Tuesday, May 5, 2009 =A0 12:25pm
// rugxulo _AT_ gmail _DOT_ com
//
// This file is (obviously?) not copyrighted, "nenies proprajho" !!
//
// Tested successfully on DR-DOS 7.03, FreeDOS 1.0++, and MS-DOS 6.22.
// (Doesn't work on XP or Vista, though.)
// ----------------------------------------------------------------------
//
// short query_con_codepage();
//
// gets currently selected display CON codepage
//
// int 21h, 6601h ("chcp") needs NLSFUNC.EXE + COUNTRY.SYS, but many
// =A0 =A0obscure codepages (e.g. FD's cp853 from EGA.CPX (CPIX.ZIP) or
// =A0 =A0Kosta Kostis' cp913 from ISOLATIN.CPI (ISOCP101.ZIP) have no
// =A0 =A0relevant data inside COUNTRY.SYS.
//
// int 21h, 440Ch 6Ah only works in MS-DOS and DR-DOS (not FreeDOS) because
// =A0 =A0FreeDOS DISPLAY is an .EXE TSR, not a device driver, and hence do=
esn't
// =A0 =A0fully support IOCTL, so they use the undocumented int 2Fh, 0AD02h
// =A0 =A0(which doesn't work in DR-DOS!). But DR-DOS' DISPLAY doesn't resp=
ond
// =A0 =A0to the typical install check i.d. anyways. FreeDOS currently only
// =A0 =A0supports COUNTRY.SYS in their "unstable" kernel 2037, but at leas=
t
// =A0 =A0their KEYB supports cp853 too (thanks, Henrique!).
//
// P.S. For MS or DR: ren ega.cpx *.com ; upx -d ega.com ; ren ega.com *.cp=
i
// ----------------------------------------------------------------------

short query_con_codepage() {
=A0 __dpmi_regs regs;

=A0 short param_block[2] =3D { 0, 437 };

=A0 regs.d.eax =3D 0x440C; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// GENERIC IO FOR=
 HANDLES
=A0 regs.d.ebx =3D 1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 // STDOUT
=A0 regs.d.ecx =3D 0x036A; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// 3 =3D CON, 0x6=
A =3D QUERY SELECTED CP
=A0 regs.x.ds =3D __tb >> 4; =A0 =A0 =A0 =A0 =A0 =A0 =A0// using transfer b=
uffer for low mem.
=A0 regs.x.dx =3D __tb & 0x0F; =A0 =A0 =A0 =A0 =A0 =A0// (suggested by DJGP=
P FAQ, hi Eli!)
=A0 regs.x.flags |=3D 1; =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// preset carry=
 for potential failure
=A0 __dpmi_int (0x21, &regs);

=A0 if (!(regs.x.flags & 1)) =A0 =A0 =A0 =A0 =A0 =A0// if succeed (carry fl=
ag set) ...
=A0 =A0 dosmemget( __tb, 4, param_block);
=A0 else { =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0// (u=
ndocumented method)
=A0 =A0 regs.x.ax =3D 0xAD02; =A0 =A0 =A0 =A0 =A0 =A0 =A0 // 440C -> MS-DOS=
 or DR-DOS only
=A0 =A0 regs.x.bx =3D 0xFFFE; =A0 =A0 =A0 =A0 =A0 =A0 =A0 // AD02 -> MS-DOS=
 or FreeDOS only
=A0 =A0 regs.x.flags |=3D 1;
=A0 =A0 __dpmi_int(0x2F, &regs);

=A0 =A0 if ((!(regs.x.flags & 1)) && (regs.x.bx < 0xFFFE))
=A0 =A0 =A0 param_block[1] =3D regs.x.bx;
=A0 }

=A0 return param_block[1];
}

#ifdef TEST
int main() {
=A0printf("\nCP%u\n",query_con_codepage() ); =A0// same as "mode con cp /st=
a"
=A0return 0;
}
#endif

// EOF

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019