1 #include <dos/dosextens.h>
2 #include <dos/dostags.h>
4 #include <proto/exec.h>
12 static ULONG
readLine(BPTR fh
, char *buf
, ULONG size
)
16 if((c
= FGets(fh
, buf
, size
)) == NULL
)
21 if(*c
== '\n' || *c
== '\r')
31 void InitCharsetTables(void)
35 for (i
= 0; i
< 65536; i
++)
37 glob
->from_unicode
[i
] = i
;
38 glob
->to_unicode
[i
] = i
;
40 glob
->from_unicode
[i
] = '_';
43 // Reads a coding table
44 BOOL
ReadUnicodeTable(STRPTR name
)
48 fh
= Open(name
, MODE_OLDFILE
);
54 while(readLine(fh
, buf
, 512*sizeof(char)))
63 if((*p
=='=') || (fmt2
= ((*p
=='0') || (*(p
+1)=='x'))))
68 i
= strtol((const char *)p
,(char **)&p
,16);
71 while(isspace(*p
)) p
++;
73 if(!strnicmp(p
, "U+", 2))
76 n
= strtol((const char *)p
,(char **)&p
,16);
81 n
= strtol((const char *)p
,(char **)&p
,0);
85 if (n
>= 0 && n
< 65536) {
86 glob
->from_unicode
[n
] = i
;
87 glob
->to_unicode
[i
] = n
;
95 return fh
? TRUE
: FALSE
;