1 #include <dos/dosextens.h>
2 #include <dos/dostags.h>
3 #include <proto/codesets.h>
5 #include <proto/exec.h>
13 #include "aros_stuff.h"
15 void InitCharset(struct CDVDBase
*global
)
19 CodesetsBase
= OpenLibrary("codesets.library", 0);
20 BUG(dbprintf(global
, "[CDVDFS] CodesetsBase 0x%p\n", CodesetsBase
));
24 global
->uniCodeset
= CodesetsFindA("UTF-16", NULL
);
25 BUG(dbprintf(global
, "[CDVDFS] Unicode codeset: 0x%p\n", global
->uniCodeset
));
30 int UTF16ToSystem(struct CDVDBase
*global
, char *from
, char *to
, unsigned char len
)
34 if (global
->uniCodeset
)
37 struct TagItem tags
[5];
40 * I have to fill in tags in this weird way because otherwise
41 * MorphOS gcc v2.95.3 generates memcpy() call here, and we have
42 * no global SysBase variable.
43 * And i can't use -lcodesets because it also requires global
45 * Please don't change this.
47 tags
[0].ti_Tag
= CSA_SourceCodeset
;
48 tags
[0].ti_Data
= (IPTR
)global
->uniCodeset
;
49 tags
[1].ti_Tag
= CSA_Source
;
50 tags
[1].ti_Data
= (IPTR
)from
;
51 tags
[2].ti_Tag
= CSA_SourceLen
;
52 tags
[2].ti_Data
= len
;
53 tags
[3].ti_Tag
= CSA_DestLenPtr
;
54 tags
[3].ti_Data
= (IPTR
)&l
;
55 tags
[4].ti_Tag
= TAG_DONE
;
58 * Unfortunately codesets.library does not allow
59 * to specify CSA_Dest and CSA_DestLen to
60 * CodesetsConvertA(), so we have to do this copy-deallocate
63 str
= CodesetsConvertStrA(tags
);
67 CodesetsFreeA(str
, NULL
);