1 #include <dos/dosextens.h>
2 #include <dos/dostags.h>
4 #include <proto/exec.h>
14 static ULONG
readLine(struct Library
*DOSBase
, BPTR fh
, char *buf
, ULONG size
)
18 if((c
= FGets(fh
, buf
, size
)) == NULL
)
23 if(*c
== '\n' || *c
== '\r')
33 void InitCharsetTables(struct Globals
*glob
)
37 for (i
= 0; i
< 65536; i
++)
39 glob
->from_unicode
[i
] = i
;
40 glob
->to_unicode
[i
] = i
;
42 glob
->from_unicode
[i
] = '_';
45 // Reads a coding table
46 BOOL
ReadUnicodeTable(struct Globals
*glob
, STRPTR name
)
49 struct Library
*DOSBase
;
51 if (!(DOSBase
= OpenLibrary("dos.library", 0)))
54 fh
= Open(name
, MODE_OLDFILE
);
60 while(readLine(DOSBase
, fh
, buf
, 512*sizeof(char)))
69 if((*p
=='=') || (fmt2
= ((*p
=='0') || (*(p
+1)=='x'))))
74 i
= strtol((const char *)p
,(char **)&p
,16);
77 while(isspace(*p
)) p
++;
79 if(!strnicmp(p
, "U+", 2))
82 n
= strtol((const char *)p
,(char **)&p
,16);
87 n
= strtol((const char *)p
,(char **)&p
,0);
91 if (n
>= 0 && n
< 65536) {
92 glob
->from_unicode
[n
] = i
;
93 glob
->to_unicode
[i
] = n
;
102 CloseLibrary(DOSBase
);
104 return fh
? TRUE
: FALSE
;