2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
6 #include <dos/dosextens.h>
7 #include <dos/dostags.h>
9 #include <proto/exec.h>
19 static ULONG
readLine(struct Library
*DOSBase
, BPTR fh
, char *buf
,
24 if ((c
= FGets(fh
, buf
, size
)) == NULL
)
29 if (*c
== '\n' || *c
== '\r')
39 void InitCharsetTables(struct Globals
*glob
)
43 for (i
= 0; i
< 65536; i
++)
46 glob
->from_unicode
[i
] = i
;
47 glob
->to_unicode
[i
] = i
;
50 glob
->from_unicode
[i
] = '_';
53 // Reads a coding table
54 BOOL
ReadUnicodeTable(struct Globals
*glob
, STRPTR name
)
57 struct Library
*DOSBase
;
59 if (!(DOSBase
= OpenLibrary("dos.library", 0)))
62 fh
= Open(name
, MODE_OLDFILE
);
68 while (readLine(DOSBase
, fh
, buf
, 512 * sizeof(char)))
77 if ((*p
== '=') || (fmt2
= ((*p
== '0')
78 || (*(p
+ 1) == 'x'))))
83 i
= strtol((const char *)p
, (char **)&p
, 16);
84 if (i
>= 0 && i
< 256)
89 if (!strnicmp(p
, "U+", 2))
92 n
= strtol((const char *)p
, (char **)&p
, 16);
97 n
= strtol((const char *)p
, (char **)&p
, 0);
101 if (n
>= 0 && n
< 65536)
103 glob
->from_unicode
[n
] = i
;
104 glob
->to_unicode
[i
] = n
;
113 CloseLibrary(DOSBase
);
115 return fh
? TRUE
: FALSE
;