Use CP437 as default charset instead IBMPC and LATIN-1; use CP850 as DOS-charset for IBMPC
This commit is contained in:
parent
6a2d2e5ef8
commit
8a29497f7d
@ -42,6 +42,7 @@
|
|||||||
#include <dpmi.h>
|
#include <dpmi.h>
|
||||||
#include <sys/farptr.h>
|
#include <sys/farptr.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <gcharset.h>
|
||||||
|
|
||||||
static char charsetbuf[256];
|
static char charsetbuf[256];
|
||||||
|
|
||||||
@ -51,7 +52,7 @@ const char *get_charset(void)
|
|||||||
int segment, selector;
|
int segment, selector;
|
||||||
__dpmi_regs regs;
|
__dpmi_regs regs;
|
||||||
|
|
||||||
strcpy(charsetbuf, "IBMPC");
|
strcpy(charsetbuf, DEFAULT_CHARSET);
|
||||||
if ((segment = __dpmi_allocate_dos_memory(3, &selector)) != -1) {
|
if ((segment = __dpmi_allocate_dos_memory(3, &selector)) != -1) {
|
||||||
regs.h.ah = 0x65;
|
regs.h.ah = 0x65;
|
||||||
regs.h.al = 0x01;
|
regs.h.al = 0x01;
|
||||||
@ -73,20 +74,23 @@ const char *get_charset(void)
|
|||||||
ULONG CCP[8];
|
ULONG CCP[8];
|
||||||
ULONG cb;
|
ULONG cb;
|
||||||
|
|
||||||
strcpy(charsetbuf, "IBMPC");
|
strcpy(charsetbuf, DEFAULT_CHARSET);
|
||||||
if(DosQueryCp(sizeof (CCP), CCP, &cb) == 0)
|
if(DosQueryCp(sizeof (CCP), CCP, &cb) == 0)
|
||||||
sprintf(charsetbuf, "CP%i", CCP[0]);
|
sprintf(charsetbuf, "CP%i", CCP[0]);
|
||||||
#else
|
#else
|
||||||
const char *cp;
|
const char *cp;
|
||||||
|
|
||||||
strcpy(charsetbuf, "LATIN-1");
|
strcpy(charsetbuf, DEFAULT_CHARSET);
|
||||||
cp = setlocale(LC_CTYPE, "");
|
cp = setlocale(LC_CTYPE, "");
|
||||||
if((cp != NULL) and ((cp = strchr(cp, '.')) != NULL)) {
|
if((cp != NULL) and ((cp = strchr(cp, '.')) != NULL)) {
|
||||||
cp++;
|
cp++;
|
||||||
|
/* Commented on reason: Non-standard charset values isn't used in unix locale, may be in very old implementations?
|
||||||
|
// Check this.
|
||||||
if(strieql(cp, "KOI8R") or strieql(cp, "KOI8"))
|
if(strieql(cp, "KOI8R") or strieql(cp, "KOI8"))
|
||||||
cp = "KOI8-R";
|
cp = "KOI8-R";
|
||||||
if(strieql(cp, "KOI8U"))
|
if(strieql(cp, "KOI8U"))
|
||||||
cp = "KOI8-U";
|
cp = "KOI8-U";
|
||||||
|
*/
|
||||||
strxcpy(charsetbuf, cp, sizeof(charsetbuf));
|
strxcpy(charsetbuf, cp, sizeof(charsetbuf));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -97,11 +101,13 @@ const char *get_dos_charset(const char *cpfrom)
|
|||||||
{
|
{
|
||||||
#if defined(__WIN32__) || defined(__MSDOS__) || defined(__OS2__)
|
#if defined(__WIN32__) || defined(__MSDOS__) || defined(__OS2__)
|
||||||
(void)cpfrom; // These platforms use DOS CP on console, so ignore request
|
(void)cpfrom; // These platforms use DOS CP on console, so ignore request
|
||||||
|
// Another way is possible in Windows: get charset using GetANSICP()
|
||||||
return "";
|
return "";
|
||||||
#else
|
#else
|
||||||
static const struct _cpmap {
|
static const struct _cpmap {
|
||||||
char *from, *to;
|
char *from, *to;
|
||||||
} cpmap[] = {
|
} cpmap[] = {
|
||||||
|
{ "IBMPC", "CP850" },
|
||||||
{ "LATIN-1", "CP437" },
|
{ "LATIN-1", "CP437" },
|
||||||
{ "KOI8", "CP866" },
|
{ "KOI8", "CP866" },
|
||||||
{ "KOI8-R", "CP866" },
|
{ "KOI8-R", "CP866" },
|
||||||
|
@ -27,7 +27,9 @@
|
|||||||
#ifndef __gcharset_h
|
#ifndef __gcharset_h
|
||||||
#define __gcharset_h
|
#define __gcharset_h
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------
|
||||||
|
// Charset is set to this value if charset can't be taken from OS
|
||||||
|
#define DEFAULT_CHARSET "CP437"
|
||||||
// ------------------------------------------------------------------
|
// ------------------------------------------------------------------
|
||||||
|
|
||||||
const char *get_charset(void);
|
const char *get_charset(void);
|
||||||
|
Reference in New Issue
Block a user